https://kotlinlang.org logo
Title
a

asad.awadia

12/08/2019, 3:49 PM
Can a channel be easily converted to a flow?
a

Adam Powell

12/08/2019, 3:50 PM
yes but it depends on how you would like it to behave
a

asad.awadia

12/08/2019, 3:50 PM
Any docs?
a

Adam Powell

12/08/2019, 3:51 PM
.consumeAsFlow()
will return a flow that is only good for one `collect`; the channel will be automatically cancelled when the collect ends if the channel was not already closed by the sender
a

asad.awadia

12/08/2019, 3:54 PM
Oh so its still hot?
a

Adam Powell

12/08/2019, 3:56 PM
yes, it's still whatever the
SendChannel
was on the producer end, though as usual, the producer will suspend on
send
if the buffer is full and there is no waiting consumer
if you want to make a cold flow using a channel to produce into, you might be looking for the
channelFlow
builder
a

asad.awadia

12/08/2019, 3:59 PM
Oh awesome yes that’s exactly what I was looking for
Thanks!!
👍 1