-
-
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
feat(store): add default generic type to Store and MockStore #2325
Conversation
I would like some feedback on what documentation should be updated? Should we go through all the examples are update them to reflect this new usage of |
Preview docs changes for 2e34f62 at https://previews.ngrx.io/pr2325-2e34f62/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
For docs, I think the usage of Store<T>
is minimal - the same counts for the guides.
The example app can benefit from a refactor imho, but this can be done in a separate PR.
Do you want me to update the usage or leave as is for the docs? |
I would leave it as is where selectors are not used. What about adding a note on where to (not) use generics? |
+1 |
@alex-okrushko @timdeschryver thoughts on the latest commit? Updated the docs |
6017272
to
696563d
Compare
696563d
to
39c1817
Compare
Based on feedback, added a section to the selectors guide on using the store default generic. Any tweaks? Or is this good? |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
A common pattern has emerged in NgRx usage where types are no longer being provided to the Store injection point, and as such, most code is just getting an empty object
{}
for the generic. The type safety is nominal as we are already using Selectors and suggesting that selectors are the preferred way to select information from the store. Selectors themselves have types, so it is nice to be able to use the Store without providing redundant, and often unused typing.Adding a default to the
Store
andMockStore
class generics, so thatStore
andMockStore
can be injected without the need for providing a type.What is the current behavior?
Currently you must provide a generic type to the
Store
class:Closes #
What is the new behavior?
After this change you can do as follows:
Does this PR introduce a breaking change?
Other information