Is there a better syntax for collecting a `Flow` t...
# coroutines
t
Is there a better syntax for collecting a
Flow
to a
Channel
than the following ?
Copy code
flow {
    coroutineScope {
        val channel = produce {
            aFlow.collect { send(it) }
        }
    }
}
I want to write a custom logic for combining 2 `Flow`s,
zip
and
combineLatest
don't fit my use case.
s
You could look at the source-code of
zip
and
combineLatest
, copy it and then modify it for your use-case.
z
val channel = aFlow.produceIn(this)
It’s more concise, but it also integrates with channel operator fusion so if the source flow is already backed by a channel, it won’t (necessarily) create another one.
💯 2