Chris Fillmore
09/21/2021, 3:28 PMpipe
function (which I just made up) available in the coroutines library? (Sends emissions from one Flow
to another FlowCollector
) :
suspend fun <T, U> Flow<T>.pipe(destination: FlowCollector<U>, transform: (T) -> U) {
collect {
destination.emit(transform(it))
}
}
It feels so obvious but I’ve been looking at the available extension functions and haven’t spotted it. Thanks!diesieben07
09/21/2021, 3:31 PMemitAll
and map
?
destination.emitAll(
source.map(transform)
)
Chris Fillmore
09/21/2021, 3:33 PMChris Fillmore
09/21/2021, 3:33 PM