-
Notifications
You must be signed in to change notification settings - Fork 26.5k
feat(router): add CanDeactivate next state argument #13560
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
@@ -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. |
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 ! |
@vicb done |
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 |
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
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