Skip to content

feat(store) use store.select with multiple selectors #3232

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

Closed

Conversation

david-shortman
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Closes #2839

What is the new behavior?

Can select from multiple selectors. Only distinct changes are output.

// returns `Observable<number, number, number>`
const counterStateWithFunc = store.select(
    (s) => s.counter1,
    (s) => s.counter2,
    (s) => s.counter3
 );

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Comment on lines +274 to +275
current instanceof SelectedValues &&
previous instanceof SelectedValues
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to use a distinct class to hold multiple selected values so that they could be distinguished from a single selected array value.

@ngrxbot
Copy link
Collaborator

ngrxbot commented Nov 12, 2021

Preview docs changes for be9e44a at https://previews.ngrx.io/pr3232-be9e44ad/

@brandonroberts
Copy link
Member

I think the discussion for this PR should be had in the issue, and not in a PR. I'm not in favor of adding new APIs for this as I think combining should be done in selectors and not with Store.select.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ComponentStore: Allow multiple selector functions to store.select
3 participants