Is there something like this `pipe` function (whic...
# flow
c
Is there something like this
pipe
function (which I just made up) available in the coroutines library? (Sends emissions from one
Flow
to another
FlowCollector
) :
Copy code
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!
d
Isn't this just a combination of
emitAll
and
map
?
Copy code
destination.emitAll(
  source.map(transform)
)
c
Yes, you’re right.
I suppose I could just do that. Thanks for the tip!