refactor(router): move activation to private method (#22033)
PR Close #22033
This commit is contained in:
parent
a57df4ee20
commit
92a5876f51
@ -712,14 +712,25 @@ export class Router {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.activateRoutes(
|
||||||
|
routerState$, this.routerState, this.currentUrlTree, id, url, rawUrl, skipLocationChange,
|
||||||
|
replaceUrl, resolvePromise, rejectPromise);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs the logic of activating routes. This is a synchronous process by default. While this
|
||||||
|
* is a private method, it could be overridden to make activation asynchronous.
|
||||||
|
*/
|
||||||
|
private activateRoutes(
|
||||||
|
state: Observable<{appliedUrl: string, state: RouterState, shouldActivate: boolean}>,
|
||||||
|
storedState: RouterState, storedUrl: UrlTree, id: number, url: UrlTree, rawUrl: UrlTree,
|
||||||
|
skipLocationChange: boolean, replaceUrl: boolean, resolvePromise: any, rejectPromise: any) {
|
||||||
// applied the new router state
|
// applied the new router state
|
||||||
// this operation has side effects
|
// this operation has side effects
|
||||||
let navigationIsSuccessful: boolean;
|
let navigationIsSuccessful: boolean;
|
||||||
const storedState = this.routerState;
|
|
||||||
const storedUrl = this.currentUrlTree;
|
|
||||||
|
|
||||||
routerState$
|
state
|
||||||
.forEach(({appliedUrl, state, shouldActivate}: any) => {
|
.forEach(({appliedUrl, state, shouldActivate}: any) => {
|
||||||
if (!shouldActivate || id !== this.navigationId) {
|
if (!shouldActivate || id !== this.navigationId) {
|
||||||
navigationIsSuccessful = false;
|
navigationIsSuccessful = false;
|
||||||
@ -781,7 +792,6 @@ export class Router {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private resetStateAndUrl(storedState: RouterState, storedUrl: UrlTree, rawUrl: UrlTree): void {
|
private resetStateAndUrl(storedState: RouterState, storedUrl: UrlTree, rawUrl: UrlTree): void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user