launch
open fun launch(context: CoroutineContext = EmptyCoroutineContext, longRunning: Boolean = false, start: CoroutineStart = CoroutineStart.DEFAULT, withLoading: MutableStateFlow<Int>? = if (longRunning) null else oneShot.loading, onError: suspend (Throwable) -> Unit? = null, block: suspend CoroutineScope.() -> Unit): Job
Launches a coroutine. Mark long-running coroutines by setting longRunning to true
.
Parameters
context
additional to CoroutineScope.coroutineContext context of the coroutine.
start
coroutine start option. The default value is CoroutineStart.DEFAULT.
withLoading
Tracks loading state for the (re-)computation. Defaults to ContextualLoading. This should be null
for long-running / never-terminating coroutines (e.g. flow.collect
).
onError
Optional custom error handler.
block
the coroutine code which will be invoked in the context of the provided scope.