https://kotlinlang.org logo
#coroutines
Title
# coroutines
r

Ruben Quadros

07/04/2022, 9:35 AM
Hi everyone, what is the difference channel
receiveAsFlow
vs
consumeAsFlow
?
receiveAsFlow
can have multiple collectors and
consumeAsFlow
only 1?
s

Sam

07/04/2022, 9:44 AM
Pretty much 👍.
consumeAsFlow
will close the channel if you start collecting the flow and then stop, or if the flow encounters an error. Whereas
receiveAsFlow
won't affect the channel, which means, as you say, that you can collect it more than once to receive more items.
🙏 1
652 Views