Jun 29, 2022
Just a heads up that using channels for events that way can cause the loss of events if you're not super careful. (I used to use this pattern too. I even wrote an article about it only to find out a few months afterwards that it's not safe.)
If you're using Dispatchers.Main.immediate throughout the entire event chain then maybe it will work, but that's brittle. Execellent article otherwise!
See for reference https://github.com/Kotlin/kotlinx.coroutines/issues/2886 . And a Kotlin playground that demonstrates the issue: https://pl.kotl.in/efsPK1wi8