I have a use case for `BroadcastChannel` but I'm n...
# coroutines
d
I have a use case for
BroadcastChannel
but I'm not sure how to expose it. Should I literally expose the
BroadcastChannel
for users to call
openSubscription()
or should I wrap this up?
z
BroadcastChannel
includes both the read side and the write side. Assuming you don't want your API consumers to be able to send their own values, it's better to keep the channel private. The read half of
BroadcastChannel
naturally maps to a
Flow
, and there's an extension function to convert it:
asFlow()
(there was even talk of making
BroadcastChannel
implement
Flow
directly for a while).
d
Thanks!