Is there any reason not to kick off a coroutine in...
# mvikotlin
s
Is there any reason not to kick off a coroutine in a renderer so that we can do the rendering work on a background thread? (cc @Casey Morris)
This is a case where our renderer is just producing a ui model that the ui later consumes.
a
What's renderer? You mean ViewRenderer?
s
Yes indeed
a
Well, ViewRenderer is supposed to update the UI, so it should be running on the UI thread. This is valid for Android Views, Swing, UIKit, etc.
Overall, all MVIKotlin components are running on the UI thread by design. There are two primary reasons for that: 1. To prevent difficult to debug race conditions. 2. To allow the UI state changes to reach the UI synchronously on the same call stack. E.g. if an intent is sent on button click or text change, then the new state should reach the UI on the same call stack. All heavy operations should be off-loaded in the Executor.