Let's have a channel (ConflatedBroadcastChannel) w...
# coroutines
j
Let's have a channel (ConflatedBroadcastChannel) wired in a model. What is an alternative to
SingleLiveData<T>
, e.g. something what observe value just once, but on multiple places (observers).
t
.take(1)
would help you?
j
I think not, tak will return just first event and also cancel parent flow -> may cancel channel
t
But a ConflatedBroadcastChannel takes 1 arguments, the initial value. It’s always keep the last value pushed into it. You could use
.value
and get an immediate result.
m
You need
flow.share
which is not here yet: https://github.com/Kotlin/kotlinx.coroutines/issues/1261
j
I don't see how share would help, I want the opossite - observe once.