-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Provide Channel.invokeOnClose { ... } function #341
Comments
I believe the semantics are such that In this sense, your val normalResult = try { someChannel.receive() }
catch(ex: ClosedReceiveChannelException){
//onClose()
throw ex
}
//regular flow similarly, you can use Also, the many coroutine factories like |
@Groostav your proposition need to consume the channel. What if we want to have an |
Why is it not possible (or maybe not so convenient?) to catch More use-cases would be appreciated. |
Here is my use case. I want the Activity to receive events from this channel but, when leaving the activity, when I cancel the |
@SalomonBrys You can do it using |
@qwwdfsad I think we have the use cases (BLE scan, BroadcastReceiver to channel…), the label should be removed, right? |
@LouisCAD OK, so that works, but it still feels like an elegant hack. |
During discussion about this feature we've decided that adding |
Just a status update here. An attempt to add Job to all the channels (#260) is sinking. We could not find a satisfactory way to merge Job and Channel state machines. The backup plan it to still introduce |
I've explained a workaround solution to the missing |
I'm currently writing an Android library that maps Bluetooth Low Energy scan callbacks to a
ReceiveChannel
.I'd like to be able to detect when the channel becomes closed for receive and for send so I can stop the scan, but it didn't find any
onClose { ... }
function onChannel
. Is there a reason it is not present, and could it be added in the future?The text was updated successfully, but these errors were encountered: