-
Notifications
You must be signed in to change notification settings - Fork 403
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): do not use refCount()
since it makes the stream cold
#1883
Conversation
Code Climate has analyzed commit 9b476ff 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.3% (0.0% change). View more on Code Climate. |
BundleMonUnchanged files (6)
Total files change -14B 0% Groups updated (2)
Unchanged groups (4)
Final result: ✅ View report in BundleMon website ➡️ |
BundleMon (NGXS Plugins)Unchanged files (28)
No change in files bundle size Unchanged groups (6)
Final result: ✅ View report in BundleMon website ➡️ |
BundleMon (Integration Projects)Files updated (4)
Total files change -339B -0.12% Final result: ✅ View report in BundleMon website ➡️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this solution! Nicely done.
Just a question, does the extra tick happen once for the app, or once for every new subscription, or an extra time for every emitted change?
I'm not really sure how this works in unit tests since ticks seem to be called illegibly there. I've just tested it in real app with patching const tick = ApplicationRef.prototype.tick;
let ticksCalled = 0;
ApplicationRef.prototype.tick = function () {
console.log(`Ticks: ${ticksCalled++}`);
return tick.call(this);
}; Ticks are called in a normal way per each event (like clicks, timers, etc), but I don't see any difference in the amount of ticks for this change in the real app (like if I change |
I'm happy with that. Thank you! |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@ngxs/form-plugin](https://github.com/ngxs/store) | dependencies | patch | [`3.7.4` -> `3.7.5`](https://renovatebot.com/diffs/npm/@ngxs%2fform-plugin/3.7.4/3.7.5) | | [@ngxs/storage-plugin](https://github.com/ngxs/store) | dependencies | patch | [`3.7.4` -> `3.7.5`](https://renovatebot.com/diffs/npm/@ngxs%2fstorage-plugin/3.7.4/3.7.5) | | [@ngxs/store](https://github.com/ngxs/store) | dependencies | patch | [`3.7.4` -> `3.7.5`](https://renovatebot.com/diffs/npm/@ngxs%2fstore/3.7.4/3.7.5) | --- ### Release Notes <details> <summary>ngxs/store</summary> ### [`v3.7.5`](https://github.com/ngxs/store/blob/HEAD/CHANGELOG.md#​375-2022-08-08) [Compare Source](ngxs/store@v3.7.4...v3.7.5) - Performance: Tree-shake no type on the action error [#​1858](ngxs/store#1858) - Fix: Give back control to `developmentMode` config property [#​1878](ngxs/store#1878) - Fix: Do not use `refCount()` since it makes selectable stream cold [#​1883](ngxs/store#1883) - Fix: Remove `?` from `ctx` parameter of lifecycle hooks since they are never undefined [#​1889](ngxs/store#1889) - Fix: Avoid incorrectly ordered state observable events [#​1908](ngxs/store#1908) - Fix: Router Plugin - Prevent router overriding valid navigation [#​1907](ngxs/store#1907) - Fix: Storage Plugin - Provide more meaningful error message when the storage quota exceeds [#​1863](ngxs/store#1863) - Fix: Storage Plugin - Ensure the deserialization is not skipped for master key [#​1887](ngxs/store#1887) - Fix: Storage Plugin - Do not re-hydrate the whole state when the feature state is added [#​1887](ngxs/store#1887) - Fix: Devtools Plugin - Enable time-traveling for navigation actions [#​1868](ngxs/store#1868) - Fix: Form Plugin - Prevent actions infinite loop with multiple `ngxsForm` directives [#​1890](ngxs/store#1890) - Fix: Do not check if the state class is injectable within the decorator since the `ɵprov` will not exist in JIT mode [#​1867](ngxs/store#1867) - Revert: revert select decorator changes and add deprecation note [#​1871](ngxs/store#1871) </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, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xNTEuMiIsInVwZGF0ZWRJblZlciI6IjMyLjE1Mi4wIn0=--> Co-authored-by: cabr2-bot <[email protected]> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1497 Reviewed-by: Epsilon_02 <[email protected]> Co-authored-by: Calciumdibromid Bot <[email protected]> Co-committed-by: Calciumdibromid Bot <[email protected]>
Issue: #1880
I don't know if there're other ways to fix that issue since using
refCount()
just makes the stream cold when there're no observers, butpublishReplay
buffers the last received value. See the issue and unit test.The
shareReplay
increases the number of ticks by 1, but fixes the issue.