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

Matt Thiffault

10/10/2019, 2:05 AM
BroadcastChannels with non-zero capacity: are messages sent before anyone subscribes dropped? Or do they sit in the queue?
s

streetsofboston

10/10/2019, 2:42 AM
When a channel's queue is full, calling
send()
will suspend (calling
offer()
won't suspend, but drops instead).
m

Matt Thiffault

10/10/2019, 3:12 AM
Understood. I'm just curious if, with a BroadcastChannel, what happens to a message if nobody has called openSubscription(), so there are no receive channels created. Are the messages buffered and then released when somebody does call openSubscription()? Or are they just dropped?
l

louiscad

10/10/2019, 6:12 AM
Channels are always hot. Flow share operator is not there yet, there's an issue on GitHub for it.
z

Zach Klippenstein (he/him) [MOD]

10/10/2019, 12:50 PM
ArrayBroadcastChannel
will drop anything sent to it when there are no subscribers.
ConflatedBroadcastChannel
will always cache the latest value sent to it, even if there are no subscribers.
👍 2
3 Views