Skip to content

Instantly share code, notes, and snippets.

@user-mw
Created April 13, 2022 06:08
Show Gist options
  • Save user-mw/974daeba3c7a783c66dbce0c2cbdb83c to your computer and use it in GitHub Desktop.
Save user-mw/974daeba3c7a783c66dbce0c2cbdb83c to your computer and use it in GitHub Desktop.
Coroutines. launch() inside
// Code
public fun CoroutineScope.launch(
context: CoroutineContext = EmptyCoroutineContext,
start: CoroutineStart = CoroutineStart.DEFAULT,
block: suspend CoroutineScope.() -> Unit
): Job {
val newContext = newCoroutineContext(context)
val coroutine = if (start.isLazy)
LazyStandaloneCoroutine(newContext, block) else
StandaloneCoroutine(newContext, active = true)
coroutine.start(start, coroutine, block)
return coroutine
}
// Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment