zcash-android-wallet-sdk / cash.z.wallet.sdk.ext / kotlinx.coroutines.flow.Flow

Extensions for kotlinx.coroutines.flow.Flow

collectWith

Utility for removing some of the boilerplate around Synchronizers and working with flows. Allows for collecting all the elements of a flow with a given scope this is useful when you want to launch multiple things in the same scope at once. Intuitively a developer may try:

fun <T> Flow<T>.collectWith(scope: CoroutineScope, block: (T) -> Unit): Unit

onFirst

Utility for performing the given action on the first emission of a flow.

suspend fun <T, S> Flow<T>.onFirst(block: suspend (T) -> S): Unit

onFirstWith

Utility for performing the given action on the first emission of a flow and running that action in the given scope.

fun <T, S> Flow<T>.onFirstWith(scope: CoroutineScope, block: suspend (T) -> S): Unit