From f419fd03d206cc247ff7dfbfad5d65ae1fd3f4b1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 26 Dec 2021 22:00:26 +0600 Subject: [PATCH] small fix of performing state update for UpdatableStatesMachine --- .../dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 {