question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Introduce broadcast() extension to turn ReceiveChannel into BroadcastChannel

See original GitHub issue

We need a broadcast operator that turns a ReceiveChannel into BroadcastChannel.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:18 (13 by maintainers)

github_iconTop GitHub Comments

4reactions
elizarovcommented, Mar 15, 2018

@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.

2reactions
elizarovcommented, Mar 16, 2018

@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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found