-
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(router): export function to run guards serially #55890
base: main
Are you sure you want to change the base?
Conversation
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.
👍
* @param guards An array of functional guards that should be executed in the declared order. | ||
* @returns The combined functional guard. | ||
*/ | ||
export function runSerially( |
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.
In order for this to be part of the public API, you also have to export it from packages/router/src/index.ts
and then run the command to accept the new public API golden: yarn bazel run //packages/router:router_api.accept
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.
Would be great to also add @publicApi
, usually at the last of the JSDoc.
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.
Thanks for the quick feedback. I will use the same JSDoc footer section as in the other functions within this file.
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
Reviewed-for: public-api
This PR will need rebase after all the recent merges. |
Deployed adev-preview for 39f4984 to: https://ng-dev-previews-fw--pr-angular-angular-55890-adev-prev-prhspsgj.web.app Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt. |
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.
Docs wise
When multiple guards are defined for a route, they run concurrently by default. There are use cases in which it is desirable to compose guards serially, e.g., when one guard depends on pre-conditions established by another one. A basic `runSerially` function existed in the tests already. This commit makes the function importable and modifies it to handle more edge cases that will occur in practical use.
1e09b6b
to
39f4984
Compare
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
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
When multiple guards are defined for a route, they run concurrently by default. There are use cases in which it is desirable to compose guards serially, e.g., when one guard depends on pre-conditions established by another one. A basic
runSerially
function existed in the tests already. This commit makes the function importable and modifies it to handle more edge cases that will occur in practical use.PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the new behavior?
A helper function is added to compose functional guards serially.
Does this PR introduce a breaking change?