Dominaezzz
07/10/2021, 1:48 PMval stream = MutableSharedFlow<Unit>()
val unused = stream.buffer(Channel.RENDEZVOUS).produceIn(GlobalScope)
stream.emit(Unit)mbonnin
07/10/2021, 1:51 PMMutableSharedFlow will drop events if there are no subscribersmbonnin
07/10/2021, 1:51 PMin the absence of subscribers emitter never suspends despite BufferOverflow.SUSPEND option and BufferOverflow.DROP_LATEST option does not have effect eitherDominaezzz
07/10/2021, 1:52 PMproduceIn a subscriber?Dominaezzz
07/10/2021, 1:53 PMstream.emit(Unit) 20 times, in a row, it suspends after the 15th emit.mbonnin
07/10/2021, 1:59 PMmbonnin
07/10/2021, 2:00 PMstream.buffer(10)
suspends at the 11th emission so looks like Channel.RENDEZVOUS isn't honouredDominaezzz
07/10/2021, 2:01 PMDominaezzz
07/10/2021, 2:01 PMbuffer(10)mbonnin
07/10/2021, 2:01 PM@Test
fun produceIn() {
runBlocking {
val stream = MutableSharedFlow<Unit>()
val unused = stream.buffer(Channel.RENDEZVOUS).produceIn(GlobalScope)
var i = 0
while (true) {
println("emitting $i")
stream.emit(Unit)
i++
}
}
}mbonnin
07/10/2021, 2:02 PMDominaezzz
07/10/2021, 2:03 PMmbonnin
07/10/2021, 2:03 PMDominaezzz
07/10/2021, 2:04 PMmbonnin
07/10/2021, 2:04 PMRENDEZVOUS :
Application of flowOn, buffer with RENDEZVOUS capacity, or cancellable operators to a shared flow has no effect.mbonnin
07/10/2021, 2:04 PMDominaezzz
07/10/2021, 2:04 PMDominaezzz
07/10/2021, 2:04 PMDominaezzz
07/10/2021, 2:05 PMmbonnin
07/10/2021, 2:06 PMDominaezzz
07/10/2021, 2:08 PMDominaezzz
07/10/2021, 2:08 PMDominaezzz
07/10/2021, 2:10 PMbuffer(1) makes it 2. 🤦🏼Zach Klippenstein (he/him) [MOD]
07/10/2021, 2:20 PMDominaezzz
07/10/2021, 2:25 PMDominaezzz
07/10/2021, 2:25 PMDominaezzz
07/10/2021, 2:33 PMproduceIn that's wrong I guess.Dominaezzz
07/10/2021, 3:46 PM