Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
emitCancel(id: number = 1, url: string = 'testUrl.com/test', reason: string = 'Test Reason') {
this.eventsSubject.next(new NavigationCancel(this.id, url, reason));
}
emitError(id: number = 1, url: string = 'testUrl.com/test', error: string = 'Test Error') {
(e: any) => {
if (isNavigationCancelingError(e)) {
router.navigated = true;
router.resetStateAndUrl(storedState, storedUrl, rawUrl);
(router.events as Subject)
.next(new NavigationCancel(id, router.serializeUrl(url), e.message));
resolvePromise(false);
} else {
router.resetStateAndUrl(storedState, storedUrl, rawUrl);
(router.events as Subject)
.next(new NavigationError(id, router.serializeUrl(url), e));
try {
resolvePromise(router.errorHandler(e));
} catch (ee) {
rejectPromise(ee);
}
}
});
private cancelCurrentNavigation() {
const currentNavigation = this.router.getCurrentNavigation();
const url = this.router.serializeUrl(currentNavigation.extractedUrl);
(this.router.events as Subject).next(new NavigationCancel(currentNavigation.id, url, ''));
(this.router as any).transitions.next({...(this.router as any).transitions.getValue(), id: 0});
}
() => {
if (navigationIsSuccessful) {
router.navigated = true;
router.lastSuccessfulId = id;
(router.events as Subject)
.next(new NavigationEnd(
id, router.serializeUrl(url), router.serializeUrl(router.currentUrlTree)));
resolvePromise(true);
} else {
router.resetUrlToCurrentUrlTree();
(router.events as Subject)
.next(new NavigationCancel(id, router.serializeUrl(url), ''));
resolvePromise(false);
}
},
(e: any) => {