question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Async loading routes

See original GitHub issue

Hello. 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:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
trochcommented, Jul 15, 2016

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.

0reactions
iotchcommented, Jul 15, 2016

thanks!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found