https://kotlinlang.org logo
Title
s

sbyrne

01/29/2020, 6:51 PM
If I have a flow being read by 2 collectors, the emitter goes as fast as the faster collector, and everything gets buffered until the slower collector reads it. How do I limit that buffer so I get backpressure from the slowest collector?
z

Zach Klippenstein (he/him) [MOD]

01/29/2020, 6:52 PM
How is your flow created?
s

sbyrne

01/29/2020, 6:53 PM
flow { while(true) { emit( calcNextValue() ) } }
Oh, I did not realize that emit() is called independently for each collector. Flow is not what I want.
My question is nonsensical I guess.
d

Dominaezzz

01/29/2020, 7:11 PM
You can use
produceIn(...)
and consume it once as a channel.