fold

inline fun <T, R> UiState<T>.fold(onSuccess: (data: T) -> R, onFailure: (throwable: Throwable) -> R, onLoading: () -> R, onIdle: () -> R): R

Applies onSuccess if state is UiState.Success, onFailure if UiState.Failure, onLoading if UiState.Loading, or onIdle if UiState.Idle.