refactor(router): move activation to private method (#22144)

PR Close #22144
This commit is contained in:
Jason Aden 2018-02-09 17:49:05 -08:00 committed by Miško Hevery
parent ca5b72461c
commit 603e50d3bf

View File

@ -703,15 +703,25 @@ export class Router {
return {appliedUrl, state: null, shouldActivate};
}
});
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
// this operation has side effects
let navigationIsSuccessful: boolean;
const storedState = this.routerState;
const storedUrl = this.currentUrlTree;
routerState$
state
.forEach(({appliedUrl, state, shouldActivate}: any) => {
if (!shouldActivate || id !== this.navigationId) {
navigationIsSuccessful = false;
@ -772,7 +782,6 @@ export class Router {
}
}
});
});
}
private resetStateAndUrl(storedState: RouterState, storedUrl: UrlTree, rawUrl: UrlTree): void {