launch

fun launch(scope: CoroutineScope, timeoutMs: Long = 0, block: suspend CoroutineScope.() -> Unit)(source)

Cancels the previous job (if any) and launches a new one in the given scope. The new job uses handledLaunch to ensure exceptions are reported.

Parameters

timeoutMs

Optional timeout in milliseconds. If > 0, the block is wrapped in withTimeout so that indefinitely-suspended coroutines (e.g. blocked DataStore reads) throw TimeoutCancellationException instead of hanging silently.