(
rawUrl: UrlTree,
source: NavigationTrigger,
restoredState: RestoredState | null,
extras: NavigationExtras,
hasUAVisualTransition?: boolean,
priorPromise?: {
resolve: (result: boolean | PromiseLike<boolean>) => void;
reject: (reason?: any) => void;
promise: Promise<boolean>;
},
)
| 663 | } |
| 664 | |
| 665 | private scheduleNavigation( |
| 666 | rawUrl: UrlTree, |
| 667 | source: NavigationTrigger, |
| 668 | restoredState: RestoredState | null, |
| 669 | extras: NavigationExtras, |
| 670 | hasUAVisualTransition?: boolean, |
| 671 | priorPromise?: { |
| 672 | resolve: (result: boolean | PromiseLike<boolean>) => void; |
| 673 | reject: (reason?: any) => void; |
| 674 | promise: Promise<boolean>; |
| 675 | }, |
| 676 | ): Promise<boolean> { |
| 677 | if (this.disposed) { |
| 678 | return Promise.resolve(false); |
| 679 | } |
| 680 | |
| 681 | let resolve: (result: boolean | PromiseLike<boolean>) => void; |
| 682 | let reject: (reason?: any) => void; |
| 683 | let promise: Promise<boolean>; |
| 684 | if (priorPromise) { |
| 685 | resolve = priorPromise.resolve; |
| 686 | reject = priorPromise.reject; |
| 687 | promise = priorPromise.promise; |
| 688 | } else { |
| 689 | promise = new Promise<boolean>((res, rej) => { |
| 690 | resolve = res; |
| 691 | reject = rej; |
| 692 | }); |
| 693 | } |
| 694 | |
| 695 | // Indicate that the navigation is happening. |
| 696 | const taskId = this.pendingTasks.add(); |
| 697 | afterNextNavigation(this, () => { |
| 698 | // Remove pending task in a microtask to allow for cancelled |
| 699 | // initial navigations and redirects within the same task. |
| 700 | queueMicrotask(() => this.pendingTasks.remove(taskId)); |
| 701 | }); |
| 702 | |
| 703 | this.navigationTransitions.handleNavigationRequest({ |
| 704 | source, |
| 705 | restoredState, |
| 706 | currentUrlTree: this.currentUrlTree, |
| 707 | currentRawUrl: this.currentUrlTree, |
| 708 | rawUrl, |
| 709 | extras, |
| 710 | hasUAVisualTransition, |
| 711 | resolve: resolve!, |
| 712 | reject: reject!, |
| 713 | promise, |
| 714 | currentSnapshot: this.routerState.snapshot, |
| 715 | currentRouterState: this.routerState, |
| 716 | }); |
| 717 | |
| 718 | // Make sure that the error is propagated even though `processNavigations` catch |
| 719 | // handler does not rethrow |
| 720 | // perf: Use `.bind` to avoid holding the other closures in this scope while this promise is unsettled. |
| 721 | return promise.catch(Promise.reject.bind(Promise)); |
| 722 | } |
no test coverage detected