Skip to content

Instantly share code, notes, and snippets.

@aleksandarzekovic
Created August 13, 2022 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleksandarzekovic/35a8b45c7cb39655817a9642c110b392 to your computer and use it in GitHub Desktop.
Save aleksandarzekovic/35a8b45c7cb39655817a9642c110b392 to your computer and use it in GitHub Desktop.
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment