-
Notifications
You must be signed in to change notification settings - Fork 25.7k
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 CanDeactivate next state argument #13560
Conversation
01455cd
to
001d283
Compare
@@ -186,7 +186,8 @@ export interface CanActivateChild { | |||
* canDeactivate( | |||
* component: TeamComponent, | |||
* route: ActivatedRouteSnapshot, |
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.
currentRoute
useValue: (c: TeamCmp, a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => { | ||
useValue: (c: TeamCmp, a: ActivatedRouteSnapshot, b: RouterStateSnapshot, | ||
nextState: RouterStateSnapshot) => { | ||
expect(nextState).toBeAnInstanceOf(RouterStateSnapshot); |
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.
we need a proper test
@@ -1624,7 +1625,9 @@ describe('Integration', () => { | |||
TestBed.configureTestingModule({ | |||
providers: [{ | |||
provide: 'CanDeactivate', | |||
useValue: (c: TeamCmp, a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => { | |||
useValue: (c: TeamCmp, a: ActivatedRouteSnapshot, b: RouterStateSnapshot, |
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.
consistency b
vs nextState
I'm not very clear on the use case but this is what should be tested in the integration test. |
7cf6d8b
to
18fd6e3
Compare
done |
canDeactivate( | ||
component: TeamCmp, currentRoute: ActivatedRouteSnapshot, | ||
currentState: RouterStateSnapshot, nextState: RouterStateSnapshot): boolean { | ||
expect(currentState.url).toEqual('/team/22'); |
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.
maybe use a log
and assert the content in test test ?
Could you please:
Thanks ! |
ea9f21d
to
648b3c7
Compare
@vicb done |
648b3c7
to
f8d1445
Compare
Could you please reword it as
|
@vicb could u reword it on merge? :) |
I would but I'm not merging this week |
This seems promising. I hope it will be merged soon. Thanks @DzmitryShylovich |
f8d1445
to
f30a96a
Compare
Adds a `nextState` argument to access the future url from `CanDeactivate`. BEFORE: canDeactivate(component: T, route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean>|Promise<boolean>|boolean; AFTER: canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<boolean>|Promise<boolean>|boolean; Closes angular#9853
f30a96a
to
7f322e2
Compare
oke, I did it |
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. |
Closes #9853