diff options
Diffstat (limited to 'client/src/app/core/routing')
-rw-r--r-- | client/src/app/core/routing/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/core/routing/preload-selected-modules-list.ts | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/client/src/app/core/routing/index.ts b/client/src/app/core/routing/index.ts new file mode 100644 index 000000000..17f3ee833 --- /dev/null +++ b/client/src/app/core/routing/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './preload-selected-modules-list' | |||
diff --git a/client/src/app/core/routing/preload-selected-modules-list.ts b/client/src/app/core/routing/preload-selected-modules-list.ts new file mode 100644 index 000000000..dd5be6ad9 --- /dev/null +++ b/client/src/app/core/routing/preload-selected-modules-list.ts | |||
@@ -0,0 +1,16 @@ | |||
1 | import { Route, PreloadingStrategy } from '@angular/router'; | ||
2 | import { Observable } from 'rxjs/Observable'; | ||
3 | import 'rxjs/add/observable/timer'; | ||
4 | import 'rxjs/add/operator/switchMap'; | ||
5 | |||
6 | export class PreloadSelectedModulesList implements PreloadingStrategy { | ||
7 | preload(route: Route, load: Function): Observable<any> { | ||
8 | if (!route.data || !route.data.preload) return Observable.of(null); | ||
9 | |||
10 | if (typeof route.data.preload === 'number') { | ||
11 | return Observable.timer(route.data.preload).switchMap(() => load()); | ||
12 | } | ||
13 | |||
14 | return load(); | ||
15 | } | ||
16 | } | ||