Introduce broadcast() extension to turn ReceiveChannel into BroadcastChannel
See original GitHub issueWe need a broadcast
operator that turns a ReceiveChannel
into BroadcastChannel
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:18 (13 by maintainers)
Top Results From Across the Web
BroadcastChannel - Kotlin
Broadcast channel is a non-blocking primitive for communication between the sender and multiple receivers that subscribe for the elements using ...
Read more >BroadcastChannel API - A message bus for the web
The Broadcast Channel API is meant for easy one-to-many communication between scripts on the same origin. Some use cases for broadcast channels:.
Read more >Coroutines Broadcast Channel/Receive channel eventbus ...
This is the eventbus implementation using Broadcast channel. (RxJava2 not allowed :( ) import kotlinx.coroutines.
Read more >Kotlin Coroutines by Tutorials, Chapter 12: Broadcast Channels
A BroadcastChannel with a capacity of three is created named kotlinChannel . Start producing items and send them in the channel, all inside...
Read more >Collect on BroadcastChannel asFlow() - CommonsWare
asFlow() for the response from the broadcast (what was previously a ReceiveChannel type). Um, call collect() : import kotlinx.coroutines.* ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@caleb-allen Channels are quite an orthogonal concept to reactive streams. Channels come from CSP (Communicating Sequential Processes) world. In that worlds channels are things that you are supposed to share between communicating processes. Channels are like queues – send at one and and receive on the other end. They are very much unlike reactive streams in many respects.
However, when we start expanding the repertoire of channels that we support (like broadcast channels discussed here) we inevitably somewhat encroach onto the territory of reactive streams which sometimes results in confusion.
Channels are not something that reactive streams might readily benefit from, but Kotlin coroutines and suspending functions in particular is something to watch for. See, reactive streams specification is quite involved precisely because it is designed to work around the lack of suspending functions in Java. Reactive streams is a clever hack to support asynchronous data streams in a language that does not support asynchrony natively. That is why Kotlin’s only interest in reactive streams is from interop standpoint. We have all sorts of adapters with reactive streams, but there is no much benefit in using them in Kotlin as is.
@caleb-allen For asynchronous functions returning a single result we have a robust language feature (suspending functions). For asynchronous streams of values we still need something in the library. Given that asynchronous functions are natively supported in the language, this library’s design will be necessary different form reactive streams (see #254).