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