1
votes

I hope the title is quite self explanatory. Nativescript now supports AOT and lazy loading, but I am struggling to achieve preloading on top of the example at https://github.com/nativescript/nativescript-sdk-examples-ng. If you run the example provided, you will notice that 1s lag between switching pages (loading different modules).

Is this possible with Nativescript 2.5?

1
Here's you can get a example github.com/sis0k0/lazyNinjas - Dlucidone
Yes, thank you, that example is showing lazy loading, but not preloading of lazy loaded routes :) I want to avoid that 1s lag, while the route is being loaded on request (i.e. preload it before the user taps on the new route). - nbo

1 Answers

1
votes

Yes it is possible, at least in NS 3.0. I asked this in nativescript forums: https://discourse.nativescript.org/t/is-it-possible-to-preload-lazy-loaded-modules/1363

It's very easy, you just have to use directly the Angular Router feature: NativeScriptRouterModule.forRoot(ROUTES, {preloadingStrategy: PreloadAllModules} // import { PreloadAllModules } from "@angular/router"; )