-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(context): add support to sort bindings for @inject.* and ContextView
#2848
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
Conversation
0572f73 to
f9f7515
Compare
jannyHou
left a comment
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.
👍 Mostly LGTM. I left a comment about the order of unknown group.
2aaa0b7 to
b024f5f
Compare
b024f5f to
9192a21
Compare
|
@raymondfeng , tiny typo.
Some extension points need to control |
|
@raymondfeng
|
|
If you could please provide an example of when it helps that bindings are |
emonddr
left a comment
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.
Looks good. Just have a few questions in the comments area.
Bindings are stored in a
|
b-admike
left a comment
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.
Got one question, otherwise LGTM.
9192a21 to
05a770f
Compare
bajtos
left a comment
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.
I like the idea of allowing @inject* consumers to specify ordering of the injected bindings 👍
The implementation looks good at design level.
However, I find the naming convention rather problematic. I feel the name sorter implies the function will perform the sort, while in reality it's a compareFunction passed to Array.prototype.sort. Let's find a better name please and update all places accordingly.
|
@raymondfeng How do you envision integration & interaction of this new feature with Extension Point/Extension pattern? Can code receiving a list of extension bindings use this new feature out of the box? |
05a770f to
5be908f
Compare
@inject.* and ContextView
Yes, I'll refactor some of the extension points to use this new feature in two flavors:
|
c25308f to
89ab031
Compare
d7d5657 to
add0552
Compare
9d1ac7d to
0b0a9b9
Compare
0b0a9b9 to
5b0407f
Compare
bajtos
left a comment
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.
Looks mostly good, I have few more minor comments to consider.
No further review is necessary as far as I am concerned, but please get at least one or two more approvals from other team members.
|
|
||
| constructor( | ||
| @inject.tag(REQUEST_BODY_PARSER_TAG, {optional: true}) | ||
| @inject(filterByTag(REQUEST_BODY_PARSER_TAG), {optional: true}) |
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.
What is the reasoning for this change? Is it just a stylistic refactoring, or does it introduce any changes in the externally-observed behavior, e.g. the order in which the parsers are invoked?
I am ok with the change, but would like to better understand the consequences.
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.
It's stylistic. IIRC, we would like to deprecate @inject.tag in the future and use @inject with a filter function instead.
| * @param bindingComparatorOrSession A function to sort matched bindings or | ||
| * resolution session if the comparator is not needed | ||
| * @param session Resolution session if the comparator is provided | ||
| */ |
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.
I think the actual implementation should not have any tsdoc comments. We have already described the two flavors recognized by the compiler when validating places calling this method. WDYT?
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.
The comments are for maintainers only. I assume strong-docs or tsdocs only expose the method signatures (not implementation).
- add ability to sort bindings by tag values - allow binding sorter on ContextView and @Inject.*
5b0407f to
428325f
Compare
This PR introduces BindingSorter to help sort bindings discovered from contexts. Some extension points need to control the order of bound extensions. Such APIs can be used to sort life cycle observers
and global interceptors after the PR is landed.
It has two commits:
BindingComparatorinterface and a utility to sort by group tag.bindingComparatorforContextViewand@inject.*.Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm testpasses on your machinepackages/cliwere updatedexamples/*were updated👉 Check out how to submit a PR 👈