-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Depreceted NGRX selectors with props #694
Comments
Hi there, thanks for the report. This is the plan for the next major (v2) release. To add a way to provide factory functions instead of selectors. |
Hi @SlasherZet, long time no see. I hope this finds you well. I'm implementing a solution and would like to hear your feedback. // toFactorySelector helps to create a factory selector
const users = toFactorySelector(
rootEntities(
rootUser(
relUserEmployees(
relUserManager(),
),
relUserManager(),
),
),
);
const users$ = store.select(
users(selectCurrentUsersIds),
);
// at some point later on
users.release(); Another one is const users = rootEntities(
rootUser(
relUserEmployees(
relUserManager(),
),
relUserManager(),
),
);
const users$ = store.select(
toStaticSelector(
users,
selectCurrentUsersIds,
),
); |
Hi, thanks for taking this up, your project has been very useful to us. 👍 In my opinion the first option would be cleaner, but am I understanding it right that the "selectCurrentUsersIds" is also a selector? Something like this if at all possible: // toFactorySelector helps to create a factory selector
const users = toFactorySelector(
rootEntities(
rootUser(
relUserEmployees(
relUserManager(),
),
relUserManager(),
),
),
);
// Get the list dynamically from somewhere
const ids = ['1', '2'];
const users$ = store.select(
users(ids),
); |
Hi there, right, Cool, then I think everything has been implemented already and I can release it tonight. const users = toFactorySelector(
rootEntities(
rootUser(
relUserEmployees(
relUserManager(),
),
relUserManager(),
),
),
);
const usersPredefined$ = store.select(
users(['1', '2']),
);
const usersDynamic$ = store.select(
users(idSelector),
); |
feat(core): factories for factory selectors for ngrx 12+ #694
v1.7.0 has been released and contains a fix for the issue. Feel free to reopen the issue or to submit a new one if you meet any problems. |
GitHub issue
In Angular 12 selectors with props are deprecated.
The suggested way of selecting the entities mentioned in quick steps would therefore be deprecated as well:
The suggested way of rewriting according to the github issue is to use factory selector like this:
Currently this is not possible because the rootEntity and rootEntities requires ids as an argument and it matches the following overload in NGRX so it is also flagged as deprecated:
The first argument is of type
which matches (for rootEntities) your type HANDLER_ROOT_ENTITIES because it contains (state, id): Array
Would it be possible to rewrite the rootEntity and rootEntities functions and/or create new ones for filtering by ids so that something like the following would work?
The idea is to move the arguments into the functions itself to avoid selector with properties.
The text was updated successfully, but these errors were encountered: