Skip to content

Instantly share code, notes, and snippets.

@RBusarow
Created January 12, 2020 00:01
Show Gist options
  • Save RBusarow/fcc1a9592142edf784e36859dfca6773 to your computer and use it in GitHub Desktop.
Save RBusarow/fcc1a9592142edf784e36859dfca6773 to your computer and use it in GitHub Desktop.
public fun MainCoroutineScope(
job: Job = SupervisorJob()
): MainCoroutineScope = object : MainCoroutineScope {
override val coroutineContext = job + Dispatchers.Main
}
public fun MainCoroutineScope(
context: CoroutineContext
): MainCoroutineScope = object : MainCoroutineScope {
override val coroutineContext = context + Dispatchers.Main
}
// repeat for the other dispatchers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment