https://kotlinlang.org logo
#coroutines
Title
# coroutines
r

r4zzz4k

01/16/2018, 4:09 PM
Do I understand correctly that there is no way to peek the last value from
ConflatedChannel
without removing it?
l

louiscad

01/16/2018, 4:10 PM
I guess you are right.
BroadcastChannel
and
ConflatedBroadcastChannel
have a
valueOrNull
and a `value`properties though
r

r4zzz4k

01/16/2018, 4:15 PM
Good catch, thank you. I was already thinking that I may need
BroadcastChannel
in this specific place so that I can pull values in several places, and this finding confirms the decision.
Hmm. Was having the following in the other place:
Copy code
val connected: ReceiveChannel<Boolean>
    get() = connectedBroadcast.openSubscription()
private val connectedBroadcast = ConflatedBroadcastChannel<Boolean>()
This way I'm disallowing clients to modify underlying channel data. It seems that for just getting the
.value
I have to put additional public property. This is quickly becoming ridiculous 🙂 (I was already pointed at https://youtrack.jetbrains.com/issue/KT-14663 earlier)
62 Views