mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-20 07:13:50 +00:00
small fix of performing state update for UpdatableStatesMachine
This commit is contained in:
parent
494812a660
commit
f419fd03d2
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user