Skip to content

docs(store): add note about using createFeatureSelector with no generic supplied to Store #3063

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

Merged

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
[ ] 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?

Closes #2780

What is the new behavior?

Added doc explaining usage of createFeatureSelector with Store

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@ngrxbot
Copy link
Collaborator

ngrxbot commented Jul 2, 2021

Preview docs changes for 88b9fde at https://previews.ngrx.io/pr3063-88b9fde3/

@brandonroberts brandonroberts added the Needs Cleanup Review changes needed label Jul 5, 2021
Comment on lines -251 to +253
When injecting `Store` into components and other injectables, it is possible to omit the generic type. If injected without the generic, the default generic is applied as follows `Store<T = object>`.
The most common way to select information from the store is to use a selector function defined with `createSelector`. TypeScript is able to automatically infer types from `createSelector`, which reduces the need to provide the shape of the state to `Store` via a generic argument.

The most common way to select information from the store is to use a selector function defined with `createSelector`. When doing so, TypeScript is able to automatically infer types from the selector function, therefore reducing the need to define the type in the store generic.
So, when injecting `Store` into components and other injectables, the generic type can be omitted. If injected without the generic, the default generic applied is `Store<T = object>`.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • removed use of passive voice
  • placed motivation to use Store without type generic at beginning of section

@brandonroberts brandonroberts removed the Needs Cleanup Review changes needed label Jul 7, 2021
@brandonroberts brandonroberts merged commit e630b52 into ngrx:master Jul 7, 2021
@david-shortman david-shortman deleted the update-createFeatureSelector-docs branch July 7, 2021 13:03
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.

select overload not match when enable strict mode in tsconfig
4 participants