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