spierce7
04/17/2019, 5:04 AMReceiveChannel
, is there a way for me to turn it into a Flow
?octylFractal
04/17/2019, 5:08 AMflow(block)
can probably still work:
val flowFromChan = flow {
recvChan.consumeEach(this::emit)
}
consumeEach
is deprecatedbdawg.io
04/17/2019, 9:07 AMReceiveChannel<T>.asFlow(): Flow<T>
extension?BroadcastChannel<T>
instead of simply ReceiveChannel<T>
(probably because flow can’t manage the lifecycle of any sort of subscription unless it uses broadcast subscriptions)
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/as-flow.htmloctylFractal
04/17/2019, 9:50 AMVsevolod Tolstopyatov [JB]
04/17/2019, 11:44 AMflow {
recvChan.consumeEach(this::emit)
}
is an option, yes.
We do not provide such extension on ReceiveChannel
because it is not cold (e.g. second collect
call to such flow will emit zero items) and does not play well with flow semantics.
We are currently thinking of alternatives (e.g. some kind of subjects), so feel free to create an issue with your use-case and desired solutiondewildte
04/18/2019, 8:47 PM