diff options
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/index.ts | 1 | ||||
-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 |
3 files changed, 18 insertions, 0 deletions
diff --git a/client/src/app/core/index.ts b/client/src/app/core/index.ts index 01b12ce7e..31322138f 100644 --- a/client/src/app/core/index.ts +++ b/client/src/app/core/index.ts | |||
@@ -2,4 +2,5 @@ export * from './auth' | |||
2 | export * from './config' | 2 | export * from './config' |
3 | export * from './confirm' | 3 | export * from './confirm' |
4 | export * from './menu' | 4 | export * from './menu' |
5 | export * from './routing' | ||
5 | export * from './core.module' | 6 | export * from './core.module' |
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 | } | ||