eygraber
11/12/2020, 6:18 AMamb
operator in Flow? I've been using a coroutines utility function in my project, but I wanted to know if there's a more "Flow" way to do it:
suspend inline fun awaitFirst(vararg funcs: suspend () -> Unit) {
supervisorScope {
select<Unit> {
funcs.forEach { func -> launch { func() }.onJoin {} }
}
coroutineContext.cancelChildren()
}
}
awaitFirst(
events.observeNextButtonClicks()::first,
events.observeDelegatedNextClicks()::first
)