MCPcopy Create free account
hub / github.com/angular/angular / scheduleNavigation

Method scheduleNavigation

packages/router/src/router.ts:654–711  ·  view source on GitHub ↗
(
    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>;
    },
  )

Source from the content-addressed store, hash-verified

652 }
653
654 private scheduleNavigation(
655 rawUrl: UrlTree,
656 source: NavigationTrigger,
657 restoredState: RestoredState | null,
658 extras: NavigationExtras,
659 hasUAVisualTransition?: boolean,
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 hasUAVisualTransition,
700 resolve: resolve!,
701 reject: reject!,
702 promise,
703 currentSnapshot: this.routerState.snapshot,
704 currentRouterState: this.routerState,
705 });
706
707 // Make sure that the error is propagated even though `processNavigations` catch
708 // handler does not rethrow
709 // perf: Use `.bind` to avoid holding the other closures in this scope while this promise is unsettled.
710 return promise.catch(Promise.reject.bind(Promise));
711 }

Callers 3

navigateByUrlMethod · 0.95

Calls 7

afterNextNavigationFunction · 0.90
resolveMethod · 0.65
addMethod · 0.65
removeMethod · 0.65
bindMethod · 0.65
catchMethod · 0.45

Tested by

no test coverage detected