You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dont call suspend functions on view-models from activities or fragments
Do launch coroutines in view-models from viewModelScope
call launch within a suspend function (unless you handle the error within the launch block)
Do switch threads using withContext(dispatcher)
Dont call suspend functions on view-models from activities or fragments
Do launch coroutines in view-models from viewModelScope
Dont call launch within a suspend function (unless you handle the error within the launch block)
Do switch threads using withContext(dispatcher)
Dont use flow unless you need to. Rx's Single, Maybe and Completable can all be handled
using regular suspend calls
Do use Flows or Channels if you need to replace an Observable or Flowable
Dont use Dispatchers.Main, Dispatchers.Default or Dispatchers.IO directly
Do inject a CoroutineDispatcher using the relevant custom dagger annotation: e.g. @Ui, @Compute or @Io.
Retrofit uses its own dispatchers internally, so you dont normally need the @Io dispatcher for api calls. although you might need it for file-writing operations etc.
Do inject the @Compute coroutine dispatcher into use-cases and repositories or anything requiring intensive computation.