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

zsperske

11/18/2020, 2:56 AM
Can anyone help me understand the use case difference for a
callbackFlow
and a
Channel
? both seem to support "hot" streams
l

louiscad

11/18/2020, 3:45 AM
The former has the latter, but it's auto-closed on cancellation of the flow collector.
As explained in their respective docs in more details.
z

Zach Klippenstein (he/him) [MOD]

11/18/2020, 4:48 AM
Channel is a synchronization primitive for communicating between coroutines. CallbackFlow is basically just shorthand for creating a channel, then launching a coroutine to send to the channel, and returning a Flow that reads from the channel.
z

zsperske

11/18/2020, 2:54 PM
much appreciated!
3 Views