Prefetch

data object Prefetch : Fetch<Nothing>

A fetch operation that has not yet been started.

This is for default states, and is not generally emitted.

Properties

Link copied to clipboard
val <T : Any> Fetch<Fetch<T>>.flatten: Fetch<T>

Flatten a nested Fetch into a single Fetch.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
inline fun <In : Out, Out : Any> Fetch<In>.flatMapFetching(transform: Fetching<In>.() -> Fetch<Out>): Fetch<Out>

Flatmap a Fetching state.

Link copied to clipboard
inline fun <In : Out, Out : Any> Fetch<In>.flatMapFinished(transform: Finished<In>.() -> Fetch<Out>): Fetch<Out>

Flatmap a Finished state.

Link copied to clipboard
inline fun <In : Out, Out : Any> Fetch<In>.flatMapPrefetch(transform: Prefetch.() -> Fetch<Out>): Fetch<Out>

Flatmap a Prefetch state.

Link copied to clipboard
inline fun <Data : Any, Output> Fetch<Data>.fold(prefetch: Prefetch.() -> Output, fetching: Fetching<Data>.() -> Output, finished: Finished<Data>.() -> Output): Output

Transform all Fetch status into the Output type.

Link copied to clipboard
infix fun <T : Any> Fetch<T>.getOrDefault(default: T): T

Unwrap the internal value of a Fetch, or default.

Link copied to clipboard
inline fun <T> Fetch<T & Any>.getOrElse(recover: (Fetch<T & Any>) -> T): T

Unwrap the internal value of a Fetch, or recover.

Link copied to clipboard
fun <T : Any> Fetch<T>.getOrNull(): T?

Unwrap the internal value of a Fetch, or null.

Link copied to clipboard
fun <T : Any> Fetch<T>.getOrThrow(): T

Unwrap the internal value of a Fetch, or throw.

Link copied to clipboard
inline fun <T : Any> Fetch<T>.isFetching(predicate: Fetching<T>.() -> Boolean): Boolean
Link copied to clipboard
inline fun <T : Any> Fetch<T>.isFinished(predicate: Finished<T>.() -> Boolean): Boolean
Link copied to clipboard
Link copied to clipboard
inline fun <In : Out, Out : Any> Fetch<In>.mapFetching(transform: Fetching<In>.() -> Out?): Fetch<Out>

Transforms Fetching.cache in place.

Link copied to clipboard
inline fun <In : Out, Out : Any> Fetch<In>.mapFinished(transform: Finished<In>.() -> Out): Fetch<Out>

Transforms Finished.result in place.

Link copied to clipboard
inline fun <In : Out, Out : Any> Fetch<In>.mapToCache(transform: Finished<In>.() -> Out? = Finished<In>::result): Fetch<Out>
Link copied to clipboard
inline fun <T : Any> Fetch<T>.onFetching(action: Fetching<T>.() -> Unit): Fetch<T>

also do an action, if Fetch is Fetching.

Link copied to clipboard
inline fun <T : Any> Fetch<T>.onFinished(action: Finished<T>.() -> Unit): Fetch<T>

also do an action, if Fetch is Finished.

Link copied to clipboard
inline fun <T : Any> Fetch<T>.onPrefetch(action: Prefetch.() -> Unit): Fetch<T>

also do an action, if Fetch is Prefetch.

Link copied to clipboard

Convert a Fetch to a Faulty by catching and wrapping any exceptions thrown by getOrThrow.

Link copied to clipboard

Convert a Fetch to a KotlinResult by catching the resultOf any exceptions thrown by getOrThrow.

Link copied to clipboard
fun <Ok : Any> Fetch<Ok>.toMaybe(): Maybe<Ok>

Convert a Fetch to a Maybe by catching and suppressing any exceptions thrown by getOrThrow.

Link copied to clipboard

Convert a Fetch to an Outcome by catching any exceptions thrown by getOrThrow.