mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-10-25 14:17:14 +00:00
small fix of performing state update for UpdatableStatesMachine
This commit is contained in:
1 parent
494812a660
commit
f419fd03d2
1 file changed
+3
-1
+3
-1
@@ -28,7 +28,9 @@ open class DefaultUpdatableStatesMachine<T : State>(
|
|||||||
|
|
||||||
override suspend fun performStateUpdate(previousState: Optional<T>, actualState: T, scope: CoroutineScope) {
|
override suspend fun performStateUpdate(previousState: Optional<T>, actualState: T, scope: CoroutineScope) {
|
||||||
statesJobsMutex.withLock {
|
statesJobsMutex.withLock {
|
||||||
statesJobs[actualState] ?.cancel()
|
if (previousState.dataOrNull() != actualState) {
|
||||||
|
statesJobs[actualState] ?.cancel()
|
||||||
|
}
|
||||||
val job = previousState.mapOnPresented {
|
val job = previousState.mapOnPresented {
|
||||||
statesJobs.remove(it)
|
statesJobs.remove(it)
|
||||||
} ?: scope.launch {
|
} ?: scope.launch {
|
||||||
|
|||||||
Reference in new issue
Block a user