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

Function runCanMatchGuards

packages/router/src/operators/check_guards.ts:265–287  ·  view source on GitHub ↗
(
  injector: EnvironmentInjector,
  route: Route,
  segments: UrlSegment[],
  urlSerializer: UrlSerializer,
  currentSnapshot: PartialMatchRouteSnapshot,
  abortSignal: AbortSignal,
)

Source from the content-addressed store, hash-verified

263}
264
265export function runCanMatchGuards(
266 injector: EnvironmentInjector,
267 route: Route,
268 segments: UrlSegment[],
269 urlSerializer: UrlSerializer,
270 currentSnapshot: PartialMatchRouteSnapshot,
271 abortSignal: AbortSignal,
272): Observable<GuardResult> {
273 const canMatch = route.canMatch;
274 if (!canMatch || canMatch.length === 0) return of(true);
275
276 const canMatchObservables = canMatch.map((injectionToken) => {
277 const guard = getTokenOrFunctionIdentity(injectionToken as ProviderToken<any>, injector);
278 const guardVal = isCanMatch(guard)
279 ? guard.canMatch(route, segments, currentSnapshot)
280 : runInInjectionContext(injector, () =>
281 (guard as CanMatchFn)(route, segments, currentSnapshot),
282 );
283 return wrapIntoObservable(guardVal).pipe(takeUntilAbort(abortSignal));
284 });
285
286 return of(canMatchObservables).pipe(prioritizedGuardValue(), redirectIfUrlTree(urlSerializer));
287}

Callers 1

matchWithChecksFunction · 0.90

Calls 9

isCanMatchFunction · 0.90
runInInjectionContextFunction · 0.90
wrapIntoObservableFunction · 0.90
takeUntilAbortFunction · 0.90
prioritizedGuardValueFunction · 0.90
redirectIfUrlTreeFunction · 0.85
mapMethod · 0.80
canMatchMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…