Skip to content
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): add prioritizedGuardValue operator optimization and allowing UrlTree return from guard #26478

Closed

Conversation

jasonaden
Copy link
Contributor

  • If all guards return true, operator returns true
  • false and UrlTree are now both valid returns from a guard
  • Both these values wait for higher priority guards to resolve
  • Highest priority false or UrlTree value will be returned

…owing UrlTree return from guard

* If all guards return `true`, operator returns `true`
* `false` and `UrlTree` are now both valid returns from a guard
* Both these values wait for higher priority guards to resolve
* Highest priority `false` or `UrlTree` value will be returned
@jasonaden jasonaden added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release area: router labels Oct 16, 2018
@mary-poppins
Copy link

You can preview 5583eb3 at https://pr26478-5583eb3.ngbuilds.io/.

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

@mhevery
Copy link
Contributor

mhevery commented Oct 16, 2018

@mhevery mhevery added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Oct 17, 2018
@mhevery mhevery closed this in fdfedce Oct 17, 2018
Copy link
Contributor

@benlesh benlesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a few small nits.

OperatorFunction<Observable<boolean|UrlTree>[], boolean|UrlTree> {
return switchMap(obs => {
return combineLatest(
...obs.map(o => o.pipe(take(1), startWith(INITIAL_VALUE as INTERIM_VALUES))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: o => o.pipe(take(1), startWith(INITIAL_VALUE as INTERIM_VALUES))) could be pulled out into it's own static function for better performance and lower memory pressure. (Also might help readability)

scan(
(acc: INTERIM_VALUES, list: INTERIM_VALUES[]) => {
let isPending = false;
return list.reduce((innerAcc, val, i: number) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: The reducer function inside of here could be pulled out into it's own static function (like above)

}, acc);
},
INITIAL_VALUE),
filter(item => item !== INITIAL_VALUE), take(1)) as Observable<boolean|UrlTree>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Adding a trailing comma will make clang format this cleaner.

mhevery pushed a commit that referenced this pull request Oct 18, 2018
…owing UrlTree return from guard (#26478)

* If all guards return `true`, operator returns `true`
* `false` and `UrlTree` are now both valid returns from a guard
* Both these values wait for higher priority guards to resolve
* Highest priority `false` or `UrlTree` value will be returned

PR Close #26478
alxhub added a commit to alxhub/angular that referenced this pull request Oct 23, 2018
… and allowing UrlTree return from guard (angular#26478)"

This was incorrectly merged to the 7.0.x patch version branch.

This reverts commit d5fa4dc.
alxhub added a commit that referenced this pull request Oct 23, 2018
… and allowing UrlTree return from guard (#26478)" (#26700)

This was incorrectly merged to the 7.0.x patch version branch.

This reverts commit d5fa4dc.

PR Close #26700
sculove pushed a commit to sculove/angular that referenced this pull request Nov 2, 2018
…owing UrlTree return from guard (angular#26478)

* If all guards return `true`, operator returns `true`
* `false` and `UrlTree` are now both valid returns from a guard
* Both these values wait for higher priority guards to resolve
* Highest priority `false` or `UrlTree` value will be returned

PR Close angular#26478
FrederikSchlemmer pushed a commit to FrederikSchlemmer/angular that referenced this pull request Jan 3, 2019
…owing UrlTree return from guard (angular#26478)

* If all guards return `true`, operator returns `true`
* `false` and `UrlTree` are now both valid returns from a guard
* Both these values wait for higher priority guards to resolve
* Highest priority `false` or `UrlTree` value will be returned

PR Close angular#26478
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: router cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants