launch

fun ViewModel.launch(useMainDispatcher: Boolean = false, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit): Job
  • Launches a coroutine using the viewModelScope in the context of a ViewModel.

  • Uses Dispatchers.Default by default.

  • Note: using EmptyCoroutineContext (the default context param of CoroutineScope.launch) will fallback to using Dispatchers.Main.immediate in Android. See viewModelScope for more info