diff --git a/core/src/main/kotlin/com/bridge/ouroboros/compose/ExecutableEffect.kt b/core/src/main/kotlin/com/bridge/ouroboros/compose/ExecutableEffect.kt index 5db06f3..3bdc019 100644 --- a/core/src/main/kotlin/com/bridge/ouroboros/compose/ExecutableEffect.kt +++ b/core/src/main/kotlin/com/bridge/ouroboros/compose/ExecutableEffect.kt @@ -3,20 +3,16 @@ package com.bridge.ouroboros.compose import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.launch import kotlin.coroutines.CoroutineContext abstract class ExecutableEffect : CoroutineScope { - private val job = SupervisorJob() - private var currentContext: CoroutineContext? = null override val coroutineContext: CoroutineContext - get() { - checkNotNull(currentContext) { "coroutineContext must be attached before invoking perform" } - return job + defaultDispatcher - } + get() = currentContext?.let { it + defaultDispatcher } + ?: error("coroutineContext must be attached before invoking perform") abstract fun EFFECT_STATE.perform(emit: EventConsumer) @@ -35,7 +31,7 @@ abstract class ExecutableEffect : CoroutineScope { companion object { @Volatile - private var defaultDispatcher: CoroutineDispatcher = Dispatchers.Main + private var defaultDispatcher: CoroutineDispatcher = Dispatchers.Default fun setDefaultDispatcher(dispatcher: CoroutineDispatcher) { defaultDispatcher = dispatcher diff --git a/example-app/build.gradle b/example-app/build.gradle index ea7bec9..bc85653 100644 --- a/example-app/build.gradle +++ b/example-app/build.gradle @@ -87,7 +87,10 @@ dependencies { implementation Libs.material testImplementation Libs.junit - testImplementation Libs.Kotest.assertions + testImplementation (Libs.Kotest.assertions){ + exclude group: 'org.jetbrains.kotlin' + } + testImplementation Libs.MockK.library testImplementation project(':test') diff --git a/test/build.gradle b/test/build.gradle index 5df18e4..c8a42c7 100644 --- a/test/build.gradle +++ b/test/build.gradle @@ -45,7 +45,9 @@ android { dependencies { api project(':core') - implementation 'io.kotest:kotest-assertions-core:5.6.0' + implementation (Libs.Kotest.assertions){ + exclude group: 'org.jetbrains.kotlin' + } } afterEvaluate {