fetch
fun <T : Any> fetch(timeout: Duration = Duration.INFINITE, recover: FetchCollector<T>.(Throwable) -> Fetch<T> = { throw it }, block: suspend FetchCollector<T>.() -> T): FetchFlow<T>
Create a new FetchFlow with the given block of code to execute.
Fetch.Initial is for default states, and is not emitted by the resulting FetchFlow.
Fetch.Fetching is emitted automatically before block is executed.
Fetch.Finished automatically encapsulates the result of block.
However, you can manually emit these statuses via emit, reset, fetching, and finished.
Return
Parameters
T
The type of the result of the fetch.
timeout
The duration to wait withTimeout for the fetch block to complete once.
block
The block of code to execute.