map

inline fun <T, R> Response<T>.map(transform: (T) -> R): Response<R>

Transforms the data in this response using the provided transform function.

If this is a Response.Success, the transform function is applied to the data. For other response types (Response.SuccessEmpty, Response.Error, Response.Loading), the response is returned unchanged with appropriate type conversion.

Return

A new response with transformed data if successful, or the original response state otherwise.

Parameters

T

The type of the original data.

R

The type of the transformed data.

transform

The function to apply to the success data.