Abhishek Bansal
02/04/2020, 10:12 AMBroadcastChannel#openSubscription.consumeAsFlow()
completes when collected? If not how do I go about cancelling subscription?
I was trying to do this in my class so that client does not have to worry about cancelling the subscription
private fun getResponseChannel(): Flow<ContentResponse> {
val channel = responseChannel.openSubscription()
return channel
.consumeAsFlow()
.onCompletion {
Timber.d("Cancelled")
channel.cancel()
}
}
But it seems that onCompletion
never gets calleddekans
02/04/2020, 10:19 AMAbhishek Bansal
02/04/2020, 10:22 AMPublishSubject
like behavior. I wish to have a broadcast channel where multiple subscribers can come and go dynamically. is this possible with this setup at all?
I cannot close original channel I just wish to close new subscription when its done.streetsofboston
02/04/2020, 12:48 PMcollect
on the Flow
returned by getResponseChannel
('un-subscribing' in Rx terms), won't cause a call to onCompletion.