<@U3ZLHBTLG> I'd define `val connectionStatus = Co...
# coroutines
e
@louiscad I'd define
val connectionStatus = ConflatedBroadcastChannel<Boolean>(false)
to keep connected/disconnected status and then whenever I need to wait for it being connected I'd do
connectionStatus.consume { while (!receive()) { /* do nothing */ } }
l
@elizarov Seems neat! The
receive()
docs say calling it "removes from the channel", but this statement is false for `BroadcastChannel`s, right? Also, what does
Conflated
means exactly?
Here's what I could implement with your suggestion: https://gist.github.com/LouisCAD/0d57c65bc9dd2e45135942e8ffb365bf Is this right? EDIT: Just edited the gist to add an
isLocked
property.
e
receive()
removes from the channel, but here we are working with
BroadcastChannel
, so each consumer opens its own channel that receives its own copy of the value that was sent.
👍🏽 1
Conflated
means that it stores the most recently sent value, so if you start consuming, then the first thing that is receive it the last state that was sent.
👍🏽 1