blob: aa1c7651639183fd4b15c70db5f4e2423c0db61d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import { Observable, timer as observableTimer, of as ofObservable } from 'rxjs'
import { switchMap } from 'rxjs/operators'
import { PreloadingStrategy, Route } from '@angular/router'
import { Injectable } from "@angular/core";
@Injectable()
export class PreloadSelectedModulesList implements PreloadingStrategy {
preload (route: Route, load: Function): Observable<any> {
if (!route.data || !route.data.preload) return ofObservable(null)
if (typeof route.data.preload === 'number') {
return observableTimer(route.data.preload).pipe(switchMap(() => load()))
}
return load()
}
}
|