improvements in Beheviour Context

This commit is contained in:
InsanusMokrassar 2022-05-21 17:33:44 +06:00
parent be027efc43
commit 562e8c7429
2 changed files with 7 additions and 1 deletions

View File

@ -2,6 +2,9 @@
## 1.1.4
* `Behaviour Builder`:
* Improvements in updates passing inside of subcontexts
## 1.1.3
* `Behaviour Builder with FSM`:

View File

@ -73,7 +73,10 @@ class DefaultBehaviourContext(
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
override val allUpdatesFlow: Flow<Update> = (additionalUpdatesSharedFlow.asSharedFlow()).let {
if (upstreamUpdatesFlow != null) {
(it + upstreamUpdatesFlow).distinctUntilChanged { old, new -> old.updateId == new.updateId }
var lastHandledUpdate = -1L
(it + upstreamUpdatesFlow).filter {
(it.updateId > lastHandledUpdate).also { passed -> if (passed) { lastHandledUpdate = it.updateId } }
}
} else {
it
}