any `ReceiveChannel.asLiveData()` implementations?
# coroutines
g
any
ReceiveChannel.asLiveData()
implementations?
s
I'm implementing something like this for our company's MVVM framework.
g
do you mind sharing a snippet?
a
If you want to keep the channel alive, you can create a producer that will only pass events when a lifecycleObserver is not destroyed. The other method, which I'm looking into for my projects, is to create a
BroadcastChannel
, and add a method that will open a subscription and listen when a lifecycle starts, and close the receiver when the subscription ends. The use of a broadcast channel is to both ensure that the send channel doesn't close and to allow multiple listeners. This is similar to how a publish subject would operate in rxjava