I have a BroadcastChannel
as a buffer. I send values at one scope and would like to observe them using flow at another.
My code is:
val channel = BroadcastChannel<Int>(1)
val observable = channel.asFlow()
someScope.launch {
channel.send(42)
}
otherScope.launch {
observable.collect {
print(it)
}
}
Some information:
- otherScope lives longer then someScope
- When collect at the same scope I received values