UNPKG

ngx-serial-route-guards

Version:

Collection of utility functions for executing functional Angular Route Guards serially.

25 lines (22 loc) 1.78 kB
import * as rxjs from 'rxjs'; import * as _angular_router from '@angular/router'; import { CanActivateFn, CanActivateChildFn, ActivatedRouteSnapshot, RouterStateSnapshot, CanDeactivateFn, CanMatchFn, Route, UrlSegment } from '@angular/router'; /** * Runs the CanActivateFn route guards serially. * @param guards Route guards to be run serially. * @returns An observable that resolves to true if all guards are valid. Otherwise it returns the value from the first guard that failed. */ declare const canActivateSerially: (guards: CanActivateFn[] | CanActivateChildFn[]) => (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => rxjs.Observable<boolean | _angular_router.UrlTree | _angular_router.RedirectCommand>; /** * Runs the CanMatchFn route guards serially. * @param guards Route guards to be run serially. * @returns An observable that resolves to true if all guards are valid. Otherwise it returns the value from the first guard that failed. */ declare const canMatchSerially: (guards: CanMatchFn[]) => (route: Route, segments: UrlSegment[]) => rxjs.Observable<boolean | _angular_router.UrlTree | _angular_router.RedirectCommand>; /** * Runs the CanDeactivateFn route guards serially. * @param guards Route guards to be run serially. * @returns An observable that resolves to true if all guards are valid. Otherwise it returns the value from the first guard that failed. */ declare const canDeactivateSerially: <TComponent>(guards: CanDeactivateFn<TComponent>[]) => (component: TComponent, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState: RouterStateSnapshot) => rxjs.Observable<boolean | _angular_router.UrlTree | _angular_router.RedirectCommand>; export { canActivateSerially, canDeactivateSerially, canMatchSerially };