Skip to content

Instantly share code, notes, and snippets.

@vvsevolodovich
Created June 2, 2020 13:25
Show Gist options
  • Save vvsevolodovich/075e31ca5154b57f6048d43258680d22 to your computer and use it in GitHub Desktop.
Save vvsevolodovich/075e31ca5154b57f6048d43258680d22 to your computer and use it in GitHub Desktop.
public actual fun launch(
context: CoroutineContext = DefaultDispatcher,
start: CoroutineStart = CoroutineStart.DEFAULT,
parent: Job? = null,
block: suspend CoroutineScope.() -> Unit
): Job {
val newContext = newCoroutineContext(context, parent)
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