https://kotlinlang.org logo
Title
z

zak.taccardi

08/31/2019, 12:04 AM
I want the subject version of a flow (a flow I can force to emit). Does this exist yet? or do I need to back it with an external channel for now?
private val channelA = Channel<Int>()
private val channelB = Channel<Int>()
private val flowA: Flow<Int> = channelA.consumeAsFlow()
private val flowB: Flow<Int> = channelB.consumeAsFlow()
suspend fun whenSourceAEmits(value: Int) {
    channelA.send(value)
}
suspend fun whenSourceBEmits(value: Int) {
    channelB.send(value)
}
o

octylFractal

08/31/2019, 1:14 AM
yes, just back it with a (broadcast) channel instead, a la
scope.broadcast { ... }.asFlow()