select-snapshot
select-snapshot copied to clipboard
Still maintaned?
Is this project still under active development and if so is there project roadmap/plan publicly available with what features are planned?
Yeah, I've published @ngxs-labs/[email protected]
which is compatible with Angular 10.0.5+. Could you give it a try?
Hello @arturovt sure thing, anything in particliar you would like me to test out?
Can this be moved out of labs and into the core version?
Can this be moved out of labs and into the core version?
This will be great ;) With this I can put all getters in one place and have much cleaner code
I've noticed that @SelectSnapshot() doesn't always return the latest value and we're in the process of removing it as it's unreliable.
@roldengarm You may be interested in using a utility like the one I made in this playground (if you are using Ivy): https://stackblitz.com/edit/ngxs-select-dispatch-utils-v0-bmecrf?file=src/app/app.component.ts
It doesn't use a decorator, but the syntax is actually simpler, and more type-safe.
The selectSnapshot
util is also slightly different in that it returns a function which you invoke from the template to get the underlying value. PS. it would not trigger change detection for you when it changes, so you would need to be aware of this.
Let me know what you think?
@roldengarm Could we have more info on this if possible?
Are the cases where it doesn't return the latest value known? We are using it across our application, and reading this makes me a bit concerned. Should we refrain from using @SelectSnapshot() at all? Will there be a replacement? What about ViewSelectSnapshot(), does this one have the same problem?
Thanks.
@mchlroy sorry for the late reply.
I couldn't pinpoint when it didn't work as expected, just noticed that it had the wrong value a couple of times. I've removed it entirely from our app.
Has this been added to the core library or is there an alternative way to leverage such functionality in the latest version of ngxs/store?
@jayordway I would recommend that you use the utility I linked in this comment:
https://stackblitz.com/edit/ngxs-select-dispatch-utils-v0-bmecrf?file=src/app/app.component.ts
It doesn't use a decorator, but the syntax is actually simpler, and more type-safe. The selectSnapshot util is also slightly different in that it returns a function which you invoke from the template to get the underlying value. PS. it would not trigger change detection for you when it changes, so you would need to be aware of this. Let me know what you think?
Ok, this project is not maintained anymore? There is any plan to bring similar feature or this from link inside ngxs?
@jayordway I would recommend that you use the utility I linked in this comment:
https://stackblitz.com/edit/ngxs-select-dispatch-utils-v0-bmecrf?file=src/app/app.component.ts
It doesn't use a decorator, but the syntax is actually simpler, and more type-safe. The selectSnapshot util is also slightly different in that it returns a function which you invoke from the template to get the underlying value. PS. it would not trigger change detection for you when it changes, so you would need to be aware of this. Let me know what you think?
We would love feedback on this utility that I linked.
You can add it into your project and use it. Depending on your angular version, you may need to change the ɵɵdirectiveInject
to inject
(now exposed in Angular 14).
The issue with the decorator approach of @SelectSnapshot
and even @Select
from the main library is that they lack the ability to provide type safety or type inference and they use a static global in order to gain access to the store. This causes issues with MFE apps and with server side rendering in some situations.
We would advise moving away from the decorator approach to the approach I linked in the example.
See this discussion on the proposed utils: https://github.com/ngxs/store/discussions/1923