With coroutines, you’re able to use select
to wait on a number of channels simultaneously. Is it possible to update the list of channels being waited on after the initial execution of the select
block? Basically, I’d like to be able to pass a channel through another channel, and then select on that.
Something roughly like this:
select<Unit> {
channel.onReceive { obj ->
obj.onReceive { inner ->
// do stuff
}
}
}
However, this doesn’t really seem to work – even when something is sent to the “inner” channel, it doesn’t ever get consumed. Is there any way to make this work?