Skip to content
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

feat(router-store): add selectQueryParam and selectRouteParam #2014

Merged
merged 3 commits into from
Jul 16, 2019

Conversation

timdeschryver
Copy link
Member

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
[x] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

NgRx 8 gave us frequently used router selectors, selectQueryParams and selectRouteParams were two of these. Often a specific param is needed instead of all the params provided, and this selector has to be created manually:

export const selectRouteId = createSelector(
  selectRouteParams,
  params => params && params['id']
);

Closes #

What is the new behavior?

This PR adds selectQueryParam and selectRouteParam, to create a selector to retrieve a specific param from the url.

Usage:

const {
  selectQueryParam,     // factory function to select a query param
  selectRouteParam,     // factory function to select a route param
} = getSelectors(selectRouter);


export const selectRouteId = selectRouteParam('id');
export const selectStatus = selectQueryParam('status');

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Select a specific query param or route param

Usage:

export const selectId = selectRouteParam('id');
export const selectRef = selectQueryParam('ref');
@ngrxbot
Copy link
Collaborator

ngrxbot commented Jul 12, 2019

Preview docs changes for 81d1bc3 at https://previews.ngrx.io/pr2014-81d1bc3/

@Odonno
Copy link
Contributor

Odonno commented Jul 12, 2019

That is amazing!

@brandonroberts brandonroberts merged commit 57fd3d7 into master Jul 16, 2019
@brandonroberts brandonroberts deleted the pr/router-param-selectors branch July 16, 2019 12:43
jordanpowell88 pushed a commit to jordanpowell88/platform that referenced this pull request Nov 14, 2019
)

Select a specific query param or route param

Usage:

export const selectId = selectRouteParam('id');
export const selectRef = selectQueryParam('ref');
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.

None yet

4 participants