icerockdev / moko-mvvm

Model-View-ViewModel architecture components for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
1k stars 95 forks source link

add public Dispatchers.UI which used in viewModelScope #26

Closed Alex009 closed 4 years ago

Alex009 commented 4 years ago

in some cases like updatePushToken we should use coroutines without ViewModel. and in this case required worked Dispatcher, but UIDispatcher is private in library. i suggest add: expect val Dispatchers.UI: CoroutineDispatcher

on android: actual val Dispatchers.UI: CoroutineDispatcher get() = Dispatchers.Main

on ios: actual val Dispatchers.UI: CoroutineDispatcher get() = UIDispatcher()

later, when coroutines multithreading will be released, we just deprecate Dispatchers.UI and on iOS pass Dispatchers.Main instead UIDispatcher

Alex009 commented 4 years ago

merged