-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(store): state stream should always return latest value even if update is queued up #1995
Conversation
…date is queued up
9ce7791
to
874e079
Compare
BundleMonFiles updated (1)
Unchanged files (2)
Total files change +260B +0.24% Groups updated (3)
Final result: ✅ View report in BundleMon website ➡️ |
BundleMon (NGXS Plugins)Unchanged files (14)
No change in files bundle size Unchanged groups (3)
Final result: ✅ View report in BundleMon website ➡️ |
BundleMon (Integration Projects)Files updated (3)
Total files change +125B +0.06% Final result: ✅ View report in BundleMon website ➡️ |
Code Climate has analyzed commit 874e079 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 96.7% (0.0% change). View more on Code Climate. |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@ngxs/form-plugin](https://github.com/ngxs/store) | dependencies | patch | [`3.8.0` -> `3.8.1`](https://renovatebot.com/diffs/npm/@ngxs%2fform-plugin/3.8.0/3.8.1) | | [@ngxs/storage-plugin](https://github.com/ngxs/store) | dependencies | patch | [`3.8.0` -> `3.8.1`](https://renovatebot.com/diffs/npm/@ngxs%2fstorage-plugin/3.8.0/3.8.1) | | [@ngxs/store](https://github.com/ngxs/store) | dependencies | patch | [`3.8.0` -> `3.8.1`](https://renovatebot.com/diffs/npm/@ngxs%2fstore/3.8.0/3.8.1) | --- ### Release Notes <details> <summary>ngxs/store</summary> ### [`v3.8.1`](https://github.com/ngxs/store/blob/HEAD/CHANGELOG.md#​381-2023-05-16) [Compare Source](ngxs/store@v3.8.0...v3.8.1) - Fix: Check if state is injectable in JIT [#​1988](ngxs/store#1988) - Fix: State stream should always return latest value even if update is queued up [#​1995](ngxs/store#1995) - Fix: Ensure `StateFactory` does not connect actions multiple times [#​2010](ngxs/store#2010) - Build: Add Angular 16 support [#​2008](ngxs/store#2008) - Refactor: Set singletons as "providedIn: root" [#​2015](ngxs/store#2015) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS45Ni4yIiwidXBkYXRlZEluVmVyIjoiMzUuOTcuMCIsInRhcmdldEJyYW5jaCI6ImRldmVsb3AifQ==--> Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1902 Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org> Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
In the current behavior the
StateStream
internal value (_value: T)
is not set immediately since its updates are queued up due to theOrderedBehaviorSubject
implementation we use. TheBehaviorSubject#getValue()
basically returnsthis._value
which isn't deterministically returns latest values. This happens when one action is dispatched after another action synchronously and the last action is trying to update the state and get it immediately:Let's say the
Action_2
does the following:We would expect to see the
newValue
equal toaction.newValue
, but it will show the previous value. BecausepatchState
update is queued up.