]>
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 | import { Injectable } from "@angular/core"; | |
5 | ||
6 | @Injectable() | |
7 | export class PreloadSelectedModulesList implements PreloadingStrategy { | |
8 | preload (route: Route, load: Function): Observable<any> { | |
9 | if (!route.data || !route.data.preload) return ofObservable(null) | |
10 | ||
11 | if (typeof route.data.preload === 'number') { | |
12 | return observableTimer(route.data.preload).pipe(switchMap(() => load())) | |
13 | } | |
14 | ||
15 | return load() | |
16 | } | |
17 | } |