Antanas A.
05/24/2019, 12:45 PMgildor
05/24/2019, 1:11 PMAntanas A.
05/24/2019, 1:23 PMclass Module(inputStream) {
val broadcast = inputStream.broadcast()
// multi usage: launch { broadcast.consumeEach { ... } }
fun output() = broadcast.openSubscription().map(...)
}
It's all ok with a consumeEach as you said, but it's not ok with channels which is returned by output() function
because they are outside of controllable scope of a modulebroadcast()
will connect to inputStream
channel and consumes from that forevergildor
05/24/2019, 3:01 PMlouiscad
05/24/2019, 6:53 PMasFlow
for a BroadcastChannel
will not solve the issue as a BroadcastChannel
stays hot while it's not been explicitly closed with close()
.gildor
05/25/2019, 12:46 AMMatej Drobnič
05/25/2019, 6:26 AM