Deprecation of @Select decorator and proposed alternative #1923
Unanswered
markwhitfeld
asked this question in
RFC & Proposals
Replies: 2 comments
-
In my team we have replaced all |
Beta Was this translation helpful? Give feedback.
0 replies
-
i still have some |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
There are issues with the decorator approach used with
@Select
:We are looking to deprecate the
@Select
decorator in future versions of NGXS.Improved alternative
Just for a bit of a preview of what we are looking at, here is a prototype I made last year:
https://stackblitz.com/edit/ngxs-select-dispatch-utils-v0-bmecrf?file=src%2Fapp%2Fapp.component.ts
It is simpler, gives type inference and type safety and uses safe Angular mechanisms to get access to the
store
.This example is in Angular 11, so there may be a minor tweak around the
ɵɵdirectiveInject
function based on the Angular version you are using.In newer versions, there is an official
inject
function.I have had some customers drop this utility in their codebase already, and are loving it!
Once we get more community feedback on this new approach and are confident that Angular has stabilised the
inject
api, then we will add some of these utils to the library.We are pretty certain that we would be adding the
select
utility that you see here, potentially thedispatch
utility (depending on how much feedback we get on the API for it), but most likely not theselectSnapshot
utility (because it is not particularly performant in this current form), unless a better alternative is proposed.Beta Was this translation helpful? Give feedback.
All reactions