fetchUnwrap

inline fun <T> FetchFlow<T & Any>.fetchUnwrap(crossinline recover: suspend (Fetch<T & Any>) -> T = { error("Fetch has not finished!") }): Flow<T>

Attempt to unwrap a FetchFlow to produce a Flow of it's result.

val fetch: Fetch<String> = Fetch.Initial
fetch.unwrap() // getOrThrow() (default behaviour)
fetch.unwrap { null } // getOrNull() (initial & fetching to null)
fetch.unwrap { "$it" } // getOrElse() (initial & fetching to string)

Return

A Flow of the result of a Fetch or the result of recover.

See also

FetchFlow.fetchOrThrow
FetchFlow.fetchOrNull
FetchFlow.fetchOrElse
FetchFlow.fetchOrDefault

Throws

if default recover value is used and fetch is initial or in progress.