Promise and lazy routes...
See original GitHub issueLooking at yrv
router (a good router!) we can see two ways of importing routes:
<Router>
<Route exact path="/promise" component={import('path/to/other-component.svelte')}/>
<Route exact path="/lazy" component={() => import('path/to/another-component.svelte')}/>
</Router>
With https://github.com/ItalyPaleAle/svelte-spa-router/blob/master/Advanced Usage.md#async-route-loading we have just the lazy one. Am I correct?
I think it would be useful (and amazing) to have both in svelte-spa-router
(three-shaked if we do not use them).
The promise way I think is amazing because I can have a lot of routes and maybe I just need to load immediately just the one I need and after that in background start downloading others.
What do you think about?
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Uncaught (in promise): Error: Cannot match any routes. URL ...
I am trying to lazy load the orders module which has two components orders and test. The orders route is working fine but...
Read more >Lazy Loading Routes | Vue Router
Lazy Loading Routes # ... When building apps with a bundler, the JavaScript bundle can become quite large, and thus affect the page...
Read more >How To Use Lazy Loading Routes in Angular | DigitalOcean
In this article, you will use lazy loading routes in an Angular ... The dynamic import is promise-based and gives you access to...
Read more >Lazy Loading Routes using an Observable with the Angular ...
The snippet above uses the loadChildren property in the Route object to lazy load the route using a Promise. This API is defined...
Read more >Lazy transitions when providing a promise as an argument to ...
It doesn't always seem to work well when passing a promise in to transitionTo , though. When the target route and its parent...
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
Thanks for the great discussion. I think y’all are right and it’s time we implement this natively in the router.
@hmmhmmhm let me know if you are able to work on a PR. If you can, I’d greatly appreciate it, but no pressure 😃
I’m scheduling this for 3.0
There’s currently work being done in #73 to support dynamically-imported routes.
Once that’s implemented, it will be possible to do a lazy loading too, by invoking
import('foo.svelte')
in your init code in main.js. Subsequent invocations toimport
, including in async routes as supported by #73, will just return the cached code.I’ll write some docs on how to do this