Skip to content

Instantly share code, notes, and snippets.

@RBusarow
Created January 12, 2020 00:03
Show Gist options
  • Save RBusarow/173a743b86b490689fc58729aebc6317 to your computer and use it in GitHub Desktop.
Save RBusarow/173a743b86b490689fc58729aebc6317 to your computer and use it in GitHub Desktop.
@ExperimentalCoroutinesApi
interface TestPolymorphicCoroutineScope : TestCoroutineScope,
DefaultCoroutineScope,
IOCoroutineScope,
MainCoroutineScope,
MainImmediateCoroutineScope,
UnconfinedCoroutineScope
@ExperimentalCoroutinesApi
private class TestPolymorphicCoroutineScopeImpl(
context: CoroutineContext = EmptyCoroutineContext
) : TestPolymorphicCoroutineScope,
// delegates all functionality to TestCoroutineScope
// uses the TestCoroutineScope factory function
// to inject the TestCoroutineDispatcher and TestCoroutineExceptionHandler into the context
TestCoroutineScope by TestCoroutineScope(context)
@ExperimentalCoroutinesApi
fun TestPolymorphicCoroutineScope(
context: CoroutineContext = EmptyCoroutineContext
): TestPolymorphicCoroutineScope = TestPolymorphicCoroutineScopeImpl(
context = context + dispatcher
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment