I’m looking at a pattern shown in the image below from a very helpful talk on Molecule by Ash Davies and Bill Phillips. I understand these snippets aren’t meant to be taken literally, but I’m having difficulty filling in some of the blanks.
1. I get
A MonotonicFrameClock is not available in this CoroutineContext...
crash when I use
viewModelScope
to launch Molecule as it is bound to
Dispatchers.Main.immediate
. My solve was to simply launch with
AndroidUiDispatcher.Main
, since having the ViewModel hold the Presenter is enough to make it survive configuration changes. Am I missing something else here?
2. What is the recommendation for emitting events within a Composable screen (or any view, for that matter)? The snippet has
events
as a SharedFlow, but it does not successfully emit an event when I call
events.tryEmit(LoginEvent)
and calling
emit
directly won’t work outside a coroutine.