fold
inline fun <T : Any, Output> FetchFlow<T>.fold(crossinline initial: suspend () -> Output, crossinline fetching: suspend () -> Output, crossinline finished: suspend (result: T) -> Output): Flow<Output>
Fold a FetchFlow into a Flow of Output.
Unlike mapFinished,
fold
places no restrictions on Output type.If Output is Fetch,
fold
can be used toflatMap
all fetch statuses.
Receiver
The Fetch to fold.
Return
The folded value of type Output.
Parameters
T
The type of the Fetch value.
Output
The type of the folded value.
initial
The lambda to transform the Fetch.Initial status into an Output.
fetching
The lambda to transform the Fetch.Fetching status into an Output.
finished
The lambda to transform the Fetch.Finished status into an Output.