Something I haven't quite figured out that has bee...
# coroutines
s
Something I haven't quite figured out that has been bothering me about the
RendezvousChannel
. The
RendezvousChannel
seems like a
PublishSubject
from RX, but the documentation says something that worries me:
An element is transferred from sender to receiver only when send and receive invocations meet in time
So I understand that before I start listening to the
Channel
, all events emitted to it won't be received. Is it possible though that if I'm already listening to events on the
Channel
that I'll miss any?
v
PublishSubject
is rather
ConflatedBroadcastChannel
than
RendezvousChannel
. In
RendezvousChannel
element can be received only by one consumer.
RendezvousChannel
documentation tries to say that sender is suspended until it meets the receiver. You can treat
RendezvousChannel
as suspending version of
BlockingArrayQueue
with zero capacity (
java.util.TransferQueue
actually).
s
Isn't
ConflatedBroadcastChannel
more like a
BehaviorSubject
, as all subscribers immediately receive the current value upon subscription?
Is there a BroadcastChannel that would provide the same behavior as
PublishSubject
, which is that all receivers are guaranteed to receive every item emitted after subscription, and all items emitted before subscription are lost to that receiver?
d
I have been looking for this too
This is what I've come up with so far, but I'm not 100% sure it's correct
Copy code
private val sender = BroadcastChannel<State>(Channel.CONFLATED)
        val broadcaster = sender.openSubscription().asPublisher()
s
I don't think that answers my question. I'm interested to see how @Vsevolod Tolstopyatov [JB] responds.
v
Yes,
ConflatedBroadcastChannel
is similar to
BehaviorSubject
(still can’t get used to
*Subject
terminology).
all receivers are guaranteed to receive every item emitted after subscription, and all items emitted before subscription are lost to that receiver?
This is plain
BroadcastChannel
.