Breaker ACT
05/14/2022, 3:26 PMval numberChannel = Channel<Int>(capacity = Channel.BUFFERED)
GlobalScope.launch {
numberChannel.send(0)
numberChannel.send(1)
numberChannel.send(2)
numberChannel.send(3)
numberChannel.send(4)
numberChannel.send(5)
numberChannel.send(6)
numberChannel.send(7)
}
GlobalScope.launch {
delay(1000)
numberChannel.receiveAsFlow()
.filter { it % 2 == 0 }
.collectLatest {
Timber.d("------Collect1: $it") //expect print: 0,2,4,6
}
}
GlobalScope.launch {
delay(2000)
numberChannel.receiveAsFlow()
.collectLatest {
Timber.d("------Collect2: $it") //expect print: 1,3,5,7
}
}
ephemient
05/15/2022, 2:54 AMfilter
will always consume, whether it passes it on or drops it.Breaker ACT
05/15/2022, 5:16 PMBreaker ACT
05/15/2022, 5:16 PM