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

ngx-quicklink is not preloading nested routes in a standalone application #150

Open
Timebutt opened this issue Mar 25, 2023 · 1 comment

Comments

@Timebutt
Copy link
Contributor

Timebutt commented Mar 25, 2023

I noticed degrade performance when refactoring my application to use the new Angular standalone components and routing when using ngx-quicklink so decided to investigate.

It turns out that if you have nested routes, ngx-quicklink incorrectly returns false for shouldPrefetch for these nested routes, as they were never correctly registered. The current implementation of ngx-quicklink relies on an internal property _loadedRoutes which is not available at runtime for standalone routing. Since current will always be an empty array, the for loop below never runs and more importantly, the children.forEach() doesn't run. This in turn is the cause of the routes not registering correctly: children is properly populated, but as the forEach is inside of a loop that never runs, the parent map never gets populated and as such findPath returns an invalid result, leading to those nested routes not prereloading correctly.

I've submitted a PR #151 to address the issue. It also updates the standalone example with the scenario I described above, using a SubComponent to recreate the nested routing. You can run the example and take a look at the network tab with and without my fix to verify both the behaviour being broken before, and fixed after.

@JesseZomer
Copy link

Also running into this issue

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