Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preloading Strategy & Lazy Loaded Modules #21

Open
Kaffiend opened this issue Sep 27, 2017 · 4 comments
Open

Preloading Strategy & Lazy Loaded Modules #21

Kaffiend opened this issue Sep 27, 2017 · 4 comments

Comments

@Kaffiend
Copy link

Kaffiend commented Sep 27, 2017

[ *] 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

@colinskow
Copy link
Owner

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.

@Kaffiend
Copy link
Author

Kaffiend commented Sep 27, 2017

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.

@colinskow
Copy link
Owner

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.

@Kaffiend
Copy link
Author

Absolutely, not a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants