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