async

fun <T> ViewModel.async(useMainDispatcher: Boolean = false, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> T): Deferred<T>
  • 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