hi everyone, why if I convert flow to a rendezvous...
# coroutines
b
hi everyone, why if I convert flow to a rendezvous channel (I need it for custom operator) and collect it, unnecessary dispatch (between collecting 1 and 2.) is performed. Is there a way to fix this?
Copy code
val flow = flowOf(1, 2)
produce(capacity = 0) { flow.collect { send(it) } }.consumeAsFlow()
   .onEach { println("each $it") }
   .launchIn(this)
I would expect there will be no difference comparing with:
Copy code
val flow = flowOf(1, 2)
flow.onEach { println("each $it") }
   .launchIn(this)
Link demonstrates unnecessary redispatch: https://pl.kotl.in/LbbXNwWzU
g
Produce starts a new coroutine under the hood, so it's already not the same