https://kotlinlang.org logo
Title
a

Arkadii Ivanov

07/26/2021, 10:44 PM
Hello everyone! I'm preparing the next major release -
3.0.0
, and I have a question/concern. You may noticed,
SuspendExecutor
has its
executeIntent
and
executeAction
methods defined as
suspend
. The base class
SuspendExecutor
accepts
mainContext
, which is usually
Dispatchers.Main
. Both methods are automatically called from inside
launch
, which has one important effect. The execution is always scheduled, and so is not synchronous. This may have some unwanted or unpredictable behaviours. The
SuspendBootstrapper
is affected as well. I have an idea - to go the same way as
ViewModel
and its
viewModelScope
. We can make all methods non-
suspend
, add
val scope: CoroutineScope
to the
SuspendExecutor
class, and let inheritors decide whether they need to switch context or not. The usage will be as on the screenshot (diff change in the sample
TodoListStoreFactory
). Please let me know what do you think. Maybe I'm missing something?
👍 1
r

rsktash

07/27/2021, 4:47 PM
Then we can rename it to
CoroutineExecutor
a

Arkadii Ivanov

07/27/2021, 4:48 PM
Sure, the relevant issue is already filed: https://github.com/arkivanov/MVIKotlin/issues/264
👍 1