MCPcopy Index your code
hub / github.com/angular/angular / afterNextNavigation

Function afterNextNavigation

packages/router/src/utils/navigations.ts:36–66  ·  view source on GitHub ↗
(router: {events: Observable<Event>}, action: () => void)

Source from the content-addressed store, hash-verified

34 * - `NavigationError`, `NavigationEnd`, or `NavigationSkipped` event emits
35 */
36export function afterNextNavigation(router: {events: Observable<Event>}, action: () => void): void {
37 router.events
38 .pipe(
39 filter(
40 (e): e is NavigationEnd | NavigationCancel | NavigationError | NavigationSkipped =>
41 e instanceof NavigationEnd ||
42 e instanceof NavigationCancel ||
43 e instanceof NavigationError ||
44 e instanceof NavigationSkipped,
45 ),
46 map((e) => {
47 if (e instanceof NavigationEnd || e instanceof NavigationSkipped) {
48 return NavigationResult.COMPLETE;
49 }
50 const redirecting =
51 e instanceof NavigationCancel
52 ? e.code === NavigationCancellationCode.Redirect ||
53 e.code === NavigationCancellationCode.SupersededByNewNavigation
54 : false;
55 return redirecting ? NavigationResult.REDIRECTING : NavigationResult.FAILED;
56 }),
57 filter(
58 (result): result is NavigationResult.COMPLETE | NavigationResult.FAILED =>
59 result !== NavigationResult.REDIRECTING,
60 ),
61 take(1),
62 )
63 .subscribe(() => {
64 action();
65 });
66}

Callers 5

nextNavigationFunction · 0.90
scheduleNavigationMethod · 0.90
navigateByUrlMethod · 0.85

Calls 1

subscribeMethod · 0.65

Tested by 1

nextNavigationFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…