Icaro Temponi
07/31/2019, 5:49 PMflow()
.conflate()
.buffer(1)
.onEach { updateNotifications() }
.launchIn(GlobalScope)
louiscad
07/31/2019, 5:52 PMZach Klippenstein (he/him) [MOD]
07/31/2019, 6:01 PMconflate
and buffer
are contradictory and will be fused, with conflate
winning:
Note that conflate operator is a shortcut for buffer with capacity of Channel.CONFLATED.
Adjacent applications of conflate/buffer, channelFlow, flowOn, produceIn, and broadcastIn are always fused so that only one properly configured channel is used for execution. Conflation takes precedence over buffer() calls with any other capacity.https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/conflate.html
louiscad
07/31/2019, 6:05 PMconflate()
always buffer latest element anyway, so you can get rid of buffer(1)
and have the desired behavior.Icaro Temponi
07/31/2019, 6:11 PMDominaezzz
07/31/2019, 6:18 PMIcaro Temponi
07/31/2019, 6:30 PMconflate
operator alone did just what I needed 👍