small fix of performing state update for UpdatableStatesMachine

This commit is contained in:
InsanusMokrassar 2021-12-26 22:00:26 +06:00
parent 494812a660
commit f419fd03d2

View File

@ -28,7 +28,9 @@ open class DefaultUpdatableStatesMachine<T : State>(
override suspend fun performStateUpdate(previousState: Optional<T>, actualState: T, scope: CoroutineScope) {
statesJobsMutex.withLock {
if (previousState.dataOrNull() != actualState) {
statesJobs[actualState] ?.cancel()
}
val job = previousState.mapOnPresented {
statesJobs.remove(it)
} ?: scope.launch {