unwrap
inline fun <T> Fetch<T & Any>.unwrap(recover: (Fetch<T & Any>) -> T = { error("Fetch has not finished!") }): T
Attempt to unwrap a Fetch to obtain it's result value.
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)
Content copied to clipboard
Return
See also
Throws
if default recover value is used and fetch is initial or in progress.