Skip to content

Commit 2f2b9f7

Browse files
authored
ability to override job (#88)
2 parents 3deeda2 + 875a3e1 commit 2f2b9f7

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎simplemvi/src/commonMain/kotlin/com/arttttt/simplemvi/store/DefaultStore.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class DefaultStore<Intent : Any, State : Any, SideEffect : Any>(
6262

6363
override val states: StateFlow<State> = _states.asStateFlow()
6464

65-
private val scope: CoroutineScope = CoroutineScope(coroutineContext + Job())
65+
private val scope: CoroutineScope = CoroutineScope(coroutineContext)
6666

6767
private val _sideEffects: CachingFlow<SideEffect> = CachingFlow(
6868
capacity = 64,

‎simplemvi/src/commonMain/kotlin/com/arttttt/simplemvi/store/StoreDsl.common.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.arttttt.simplemvi.config.simpleMVIConfig
55
import com.arttttt.simplemvi.logging.LoggingPlugin
66
import com.arttttt.simplemvi.plugin.StorePlugin
77
import kotlinx.coroutines.Dispatchers
8+
import kotlinx.coroutines.Job
89
import kotlin.coroutines.CoroutineContext
910

1011
/**
@@ -25,7 +26,7 @@ import kotlin.coroutines.CoroutineContext
2526
public fun <Intent : Any, State : Any, SideEffect : Any> createStore(
2627
name: StoreName?,
2728
initialize: Boolean = true,
28-
coroutineContext: CoroutineContext = Dispatchers.Main.immediate,
29+
coroutineContext: CoroutineContext = Dispatchers.Main.immediate + Job(),
2930
initialState: State,
3031
initialIntents: List<Intent> = emptyList(),
3132
plugins: List<StorePlugin<Intent, State, SideEffect>> = emptyList(),

0 commit comments

Comments
 (0)