Last active
December 27, 2019 20:58
-
-
Save adrianfaciu/33fb44d7af5909d8dbfacd27c57352e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AppPreloadingStrategy implements PreloadingStrategy { | |
preload(route: Route, load: Function): Observable<any> { | |
const loadRoute = (delay) => delay | |
? timer(150).pipe(flatMap(_ => load())) | |
: load(); | |
return route.data && route.data.preload | |
? loadRoute(route.data.delay) | |
: of(null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import {PreloadingStrategy, Route} from '@angular/router';
import {Observable, of, timer} from 'rxjs';
import {flatMap} from 'rxjs/operators';