Last line returns `true`, but I suppose it should ...
# coroutines
t
Last line returns
true
, but I suppose it should be
false
. Is it a bug, or right behavior?
e
That is how it should be. TL;DR It is due to cold/hot mismatch between channels and observable.
👍 1
When you
openSubscription()
you get a channel, which is hot and keeps observer until you close it.
However, when you convert channel to observable with
asObservable
it works just like any other hot->cold converter. The underlying channel is not closed, but you can subscribe to it many time, each subscriber receiving its share of events in fan-out faschion.
Long story short, when you
openSubscription
it becomes your duty to ultimately cancel it.
t
Should this:
Copy code
downsteamChannel.invokeOnClose {
        upstreamChannel.cancel()
    }
work if I insert this somewhere between
openSubscription()
and
asObservable()
?
t
yes, this works. Thank you!