angular-electron-dream-starter icon indicating copy to clipboard operation
angular-electron-dream-starter copied to clipboard

Preloading Strategy & Lazy Loaded Modules

Open Kaffiend opened this issue 8 years ago • 4 comments

[ *] question about the decisions made in the repository

  • What is the current behavior? Currently the routing preloading strategy is set to PreloadAllModules. What is purpose of this when demonstrating lazy loaded modules? Yes technically they are still lazy loaded after initial load. but when managing state of an application and state is loaded asynchronously this kind of defeats the purpose doesn't it? All modules not protected by a CanLoad guard will be loaded immediately.

Please refer to this question on NGRX

Kaffiend avatar Sep 27 '17 00:09 Kaffiend

This behavior comes from the upstream repository that I forked. I had nothing to do with it.

What's happening is it bootstraps the root module, and then waits for the browser idle event. When the browser is idle it loads all the additional modules in the background. This has the advantage that when the user navigates to a lazy-loaded module it will be pre-loaded, but without delaying the overall start time of the application.

colinskow avatar Sep 27 '17 01:09 colinskow

Right, I understand that and agree to the advantages, but should there be some explanation perhaps in a comment above the router configuration for less experienced seed users? It could be misleading seeing a lazy loaded module's state in the dev tools when they haven't actually called that module yet. I'm speaking strictly from a state management point of view obviously, and there comes a point in larger scale applications when full asynchronous state is more of a requirement...or luxury.

Edit: Please don't misunderstand me, i'm not trying to nit pick. These are just things i notice having a team comprised of different skill levels in the same stack. Things i find, helpful and time saving as things progress.

Kaffiend avatar Sep 27 '17 01:09 Kaffiend

Yeah, I had a discussion a while ago with the folks from AngularClass because I thought it was a bug all the modules where loading at once. PR welcome to explain this in the documentation.

colinskow avatar Sep 27 '17 01:09 colinskow

Absolutely, not a problem.

Kaffiend avatar Sep 27 '17 01:09 Kaffiend