collapse

inline fun <Ok : Any, Error : Any, Output> OutcomeFlow<Ok, Error>.collapse(crossinline success: suspend (Ok) -> Output, crossinline failure: suspend (Error) -> Output): Flow<Output>


Collapse the receiver Outcome into either value or error, using the nearest common Ancestor as the type.

Use Outcome.fold with success and failure lambda arguments to directly map each state to a specific Output type instead.

Receiver

The Outcome to collapse.

Return

The collapsed value of the nearest common Ancestor type.

Parameters

Ancestor

The nearest common ancestor type of Ok and Error.

Ok

The type of the Outcome.Success value.

Error

The type of the Outcome.Failure error.

See also