import { Injectable } from '@angular/core' ; import { ActivatedRouteSnapshot , Resolve , Router } from '@angular/router' ; import { of , Observable } from 'rxjs' ; import { catchError , take } from 'rxjs/operators' ; import { PingService } from '@core/services/index.service' ; import { PingModel } from '@shared/models/index.model' ; @ Injectable ( { providedIn : 'root' , } ) export class PingsResolver implements Resolve < PingModel [ ] > { param pingService param router constructor ( private pingService , private router ) { } param route resolve ( route ) { return this . pingService . findAllByMonitor ( route . params . projectUid , route . params . monitorUid ) . pipe ( take ( 1 ) , catchError ( ( ) => { this . router . navigate ( [ '/projects' , route . params . projectUid , 'monitors' ] ) ; return of ( [ ] ) ; } ) ) ; } }