diff --git a/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt b/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt index 91cfb680d04..deadfb62324 100644 --- a/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt +++ b/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt @@ -28,7 +28,9 @@ open class DefaultUpdatableStatesMachine( override suspend fun performStateUpdate(previousState: Optional, actualState: T, scope: CoroutineScope) { statesJobsMutex.withLock { - statesJobs[actualState] ?.cancel() + if (previousState.dataOrNull() != actualState) { + statesJobs[actualState] ?.cancel() + } val job = previousState.mapOnPresented { statesJobs.remove(it) } ?: scope.launch {