-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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(http): add has()
method to HttpContext
class
#43887
Conversation
@HyperLife1119 - thanks for this PR. |
I think it should be ok. 😄 |
Great! As expected we now have a couple more steps due to the new public API. Please run And then save it as a fixup commit (e.g. |
I finished. |
One more rebase please @HyperLife1119 - then I think we are good on this. |
You seem to have automatically closed the PR by pushing zero commits? Did you accidentally reset the branch to master rather than rebasing? |
Wait a minute, i'm recovering... |
I think this is the commit you need 8ba2a36 |
It should be ok now. @petebacondarwin |
expect(context.get(IS_ENABLED)).toBe(false); | ||
expect([...context.keys()]).toEqual([ | ||
IS_ENABLED | ||
]); // value from factory function is stored in the map upon access | ||
|
||
context.set(IS_ENABLED, true); | ||
expect(context.has(IS_ENABLED)).toBe(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.
So I actually hoped for this line to be above the line that sets the value to true. I think it is a stronger test of .has()
if the stored value is falsy.
All right. @petebacondarwin |
At present, the get() method provided by HttpContext will never return null. Sometimes we need to check whether an http token is included, so add the has() method to HttpContext.
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 to me. Thanks.
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.
Reviewed-for: public-api
This is my first PR to angular, thank you for your guidance. @petebacondarwin |
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.
@HyperLife1119 thanks for contributing to Angular! 👍
I just wanted to mention that this change adds some non-tree-shakable code to app bundles in case HTTP package is used. However the added code would be small and the new API looks reasonable (and somewhat missing in the current implementation), so we can probably justify that minimal size increase.
Reviewed-for: public-api
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.
LGTM 🍪
Thanks for your contribution!
reviewed-for: public-api
This PR was merged into the repository by commit d452b38. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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?
Unable to determine whether a certain token exists in
HttpContext
.What is the new behavior?
Use the
has()
method provided byHttpContext
to detect whether a certain token existsDoes this PR introduce a breaking change?
Other information