Hi. Am i understanding correctly that `Channel.rec...
# flow
j
Hi. Am i understanding correctly that
Channel.receiveAsFlow
can process individual items in parallel by collectors? Or is it an internal "fan out". I just want to process a queue of emissions in parallel. Thanks!
Copy code
val flow = channel.receiveAsFlow()
repeat(5) {  launch { flow.collect { /*receive channel item in separate coroutine */ } } }
n
Your code snippet is basically equivalent to:
Copy code
repeat(5) {  launch { channel.consumeEach { /*receive channel item in separate coroutine */ } } }
Items are processed concurrently, not sequentially.
👍 1
s
A nice playground to play around with this and see how it behaves. https://pl.kotl.in/uP1JO2xX8
j
thank you both. thats what i was hoping for.