Is this pyramid of death style of receiving from c...
# coroutines
w
Is this pyramid of death style of receiving from channels pretty common or am I doing something silly?
Copy code
launch {
        whileSelect {
            channel.onReceive {
                when (it) {
// do stuff
                 }
             }
        }
}
e
You don’t need
whileSelect
here. Use
for (msg in channel)
w
the
for (msg in channel)
will stop looping once there are no events though, correct? I want to continue listening on the channel even if there are 0 events.
e
Listening for what?
w
More events. I’m using the channel like an Rx.Observable in that I expect to receive events as actions happen on the UI of an application, such as
onClick { channel.send(event) }
. It works very well, though maybe I’m doing it incorrectly.
Ok thank you for the help 🙂