-
Notifications
You must be signed in to change notification settings - Fork 405
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): improve selector decorator types (#1929) #2042
feat(store): improve selector decorator types (#1929) #2042
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit d6be8b6. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 3 targetsSent with 💌 from NxCloud. |
e468148
to
71e1ad5
Compare
71e1ad5
to
d6be8b6
Compare
BundleMonUnchanged files (3)
Total files change -2B 0% Groups updated (1)
Unchanged groups (2)
Final result: ✅ View report in BundleMon website ➡️ |
BundleMon (NGXS Plugins)Unchanged files (16)
No change in files bundle size Unchanged groups (3)
Final result: ✅ View report in BundleMon website ➡️ |
BundleMon (Integration Projects)Unchanged files (2)
No change in files bundle size Final result: ✅ View report in BundleMon website ➡️ |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit a4eaf0b. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targetsSent with 💌 from NxCloud. |
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.
@ConnorUllmann Thank you so much for this contribution!
My apologies for the long delay in reviewing this.
We would like to include your PR in NGXS v17, which is landing very soon.
Would it be possible to add some comments / descriptions to the types that you created which explain how they work / what they do / etc. so that it is easier for us to be able to understand and maintain this code into the future?
One other quick comment is that after this PR is merged, we would like to build on top of your changes to add a deprecation notice to any occurrence of the @Selector(...)
decorator where the selector function is expecting the container state as the first parameter (except for the parameterless version). I am just trying to figure out where exactly that doc comment would be 😄 .
@markwhitfeld Glad to hear it! I'm writing up the descriptions of those types now. I had to make some modifications in order to allow the parameterless call to not be deprecated when injecting container state while deprecating the version of the call with parameters. Do the examples in the image below accurately cover what you're expecting to see deprecated? I can include the deprecation myself in my update, if you like, otherwise I'll note where it will need to be put. |
Yes, I agree with what you have there.
The deprecation notice should point to the page that will go live when the release goes out: https://ngxs.io/deprecations/inject-container-state-deprecation.md You can see the development version of this page here. |
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.
Fantastic work.
Can I ask you to name the T
and U
type placeholders according to what they are?
This should be the last puzzle piece to make this more understandable and therefore maintainable.
Code Climate has analyzed commit a4eaf0b and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 95.3% (0.0% change). View more on Code Climate. |
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.
Thank you so much. This is really super work!
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The
@Selector
decorator does not enforce that the arguments of the decorated function match the return types of the selectors that it depends on.Issue Number: #1929
What is the new behavior?
The
@Selector
decorator enforces that the arguments of the functions that it decorates match the return values of the selectors that it was passed.Limitations:
StateToken
works correctly).Does this PR introduce a breaking change?
Although this is not a breaking change in the sense that a codebase with correct typings on their selector functions will require no changes, the purpose of this change is to expose failures to do that typing correctly and prevent them in the future. As a result, I would expect any reasonably-sized codebase to require fixes to their selector implementations as a result of this change.