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.

However, you can manually emit these statuses via emit, reset, fetching, and finished.

Return

FetchFlow -- a Flow that encapsulates the Fetch behaviour.

Parameters

T

The type of the result of the fetch.

timeout

The duration to wait withTimeout for the fetch block to complete once.

recover

The transformation to apply to any non-fatal Throwable that is caught.

block

The block of code to execute.

See also