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

Function callGuard

packages/router/src/operators/check_guards.ts:261–267  ·  view source on GitHub ↗

* Calls a guard right away, but delivers a synchronous throw as an observable error so that * `prioritizedGuardValue` orders it with the other guards' results.

(guardFn: () => T | Promise<T> | Observable<T>)

Source from the content-addressed store, hash-verified

259 * `prioritizedGuardValue` orders it with the other guards' results.
260 */
261function callGuard<T>(guardFn: () => T | Promise<T> | Observable<T>): Observable<T> {
262 try {
263 return wrapIntoObservable(guardFn());
264 } catch (e) {
265 return new Observable<T>((subscriber) => subscriber.error(e));
266 }
267}
268
269function redirectIfUrlTree(urlSerializer: UrlSerializer): OperatorFunction<GuardResult, boolean> {
270 return pipe(

Callers 3

runCanDeactivateFunction · 0.85
runCanLoadGuardsFunction · 0.85
runCanMatchGuardsFunction · 0.85

Calls 2

wrapIntoObservableFunction · 0.90
errorMethod · 0.65

Tested by

no test coverage detected