Async loading routes
See original GitHub issueHello.
What’s the best way to load a part of the routes definition on demand?
For example, if app is big and code needs to be split - what’s the approach to load child routes and associated code on transition to that route, and after the route loaded wait for all children’s onActivate
to resolve?
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Loading async data - Router5
Loading async data is always an important task of a web application. Very often, data and routes are tied to your application business...
Read more >How to make a route load different components based on ...
How to make a route load different components based on async user data on Angular. Stop using endless *ngIfs! It's time to start...
Read more >How To Handle Async Data Loading, Lazy Loading, and Code ...
In this step, you asynchronously loaded components. You used lazy and Suspense to dynamically import components and to show a loading message ...
Read more >Async load routes data and build route instruction for Angular 2
You can load components asynchronously by providing a SystemJsComponentResolver. Right now, you can load routes asynchronously and imperatively ...
Read more >Lazy Loading Routes | Vue Router
Do not use Async components for routes. Async components can still be used inside route components but route component themselves are just dynamic...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah OK I see. router5 doesn’t offer that kind of route matching (load and pray), it doesn’t need to. I believe react-router came to that solution because they needed to support code splitting, and they could only achieve it that way since with
<Route />
you do two things: you register a route, and you map that route to a component. With router5, route registration is not tied to component mapping, so you can define all your possible URLs up-front and then let your view react to route changes.I conceptually treat code-splitting the same way I treat data loading: I trigger component loading if needs be on a route change with a container component displaying a loading feedback during the time the required component is not available. Once it is available, it renders it.
thanks!