-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow Selector to accept arguments besides state #1152
Comments
Selectors can already be created using arrays. See https://github.com/ngrx/platform/blob/master/modules/store/spec/selector.spec.ts#L126 |
@brandonroberts const getUser = (state, id) => {
return state.userLists[id]
}
const user = getUser(state, someId); in this example, the selector function |
@brandonroberts |
What's your proposed change? |
@brandonroberts and update Selector interface like below: interface Selector<T, V, P = {}> {
(state: T, props?: P): V;
} |
If this is something we want, I can provide a PR. |
Seems reasonable to me. Let @tsugitta put in the PR if they still want to work this change. |
thanks, let me try to submit the PR. |
@timdeschryver |
Does documentation of the selectors reflect this change ? I tried to check there but couldn't find it out. |
It's documented at https://ngrx.io/guide/store/selectors#using-selectors-with-props @Abhay-Joshi-Git . Are the docs missing something? |
ok, thanks for sharing this. |
Thanks for this awesome library!
With Reselect, we can call a selector with arguments like below (almost copied from Reselect's README):
but ngrx's selector does not seem to have such a feature. It will be helpful for me if it's possible.
Other information:
In the above example of Reselect, the props is not used in
createSelector
, but actually it also can be used like below:ref: reduxjs/reselect#272 (comment)
If accepted, I would be willing to submit a PR for this feature
[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered: