Created
January 23, 2021 14:09
-
-
Save PandiyanCool/03e1eb6a4a5b250ea1eed213642ec266 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
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class CustomPreload implements PreloadingStrategy { | |
preload(route: Route, load: (): Observable<any>): Observable<any> { | |
// you implement this function somewhere, somehow | |
if (isActiveCardRoute(route)) { | |
// this will make it load immediately | |
return load(); | |
} else { | |
/* | |
* this will load the remaining modules after 5 seconds. You can possibly make a more | |
* 'complex' logic to have it load sequentially or in bigger intervals to make sure | |
* the app doesn't lag when loading | |
*/ | |
return timer(5000).pipe( | |
switchMap(() => load()) | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment