File

src/lib/is-app-ready.guard.ts

Index

Methods

Constructor

constructor(lifecycle: LifeCycleService)
Parameters :
Name Type Optional
lifecycle LifeCycleService No

Methods

Public canActivate
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot)
Parameters :
Name Type Optional
next ActivatedRouteSnapshot No
state RouterStateSnapshot No
Returns : Observable<boolean>
import { Injectable } from '@angular/core';
import {
  ActivatedRouteSnapshot,
  RouterStateSnapshot,
} from '@angular/router';
import { Observable } from 'rxjs';
import { LifeCycleService } from './life-cycle.service';

@Injectable({
  providedIn: 'root',
})
export class IsAppReadyGuard {

  constructor(private readonly lifecycle: LifeCycleService) {
  }

  public canActivate(
    next: ActivatedRouteSnapshot,
    state: RouterStateSnapshot,
  ): Observable<boolean> {
    console.debug('[IsAppReadyGuard] can activate', state.url);
    return this.lifecycle.whenReady(() => true);
  }

}

results matching ""

    No results matching ""