Add some new lifecycle hooks for components
See original GitHub issueHello,
I would like to propose add some some new lifecycle hooks for components including async ones.
Now it too difficult to know when async components are loaded and you need to add some wrappers:
https://github.com/vuejs/vue/blob/dev/test/unit/features/component/component-async.spec.js#L62 https://github.com/vuejs/vue/blob/dev/test/unit/features/component/component-async.spec.js#L70
It would nice to use built in lifecycle hooks instead:
import Vue from 'vue';
const vm = new Vue({
components: {
component1: resolve => {
require(['./component1'], resolve);
},
component2: resolve => {
require(['./component2'], resolve);
},
component3: resolve => {
require(['./component3'], resolve);
}
// etc
},
ready() {
console.log('All components are loaded', components);
// For instance, you may use `expect` here for tests
}
});
vm.$mount();
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Lifecycle hooks - Angular
Your application can use lifecycle hook methods to tap into key events in the lifecycle of a component or directive to initialize new...
Read more >Lifecycle Hooks • Angular - codecraft.tv
To do this we add some specific methods to our component class which get called during each of these life-cycle phases, we call...
Read more >Angular lifecycle hooks explained - LogRocket Blog
A guide to lifecycle hooks in Angular, including what they do, and how to use them to gain more control over your applications....
Read more >Lifecycle Hooks in Web Components - Ultimate Courses
Lifecycle hooks are great, because you don't have to invent a completely new system for constructing and deconstructing elements yourself.
Read more >Complete Guide: Angular lifecycle hooks - InDepth.Dev
In this article, we will take a deeper dive into each lifecycle hook and look at how they're used in Angular.
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 FreeTop 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
Top GitHub Comments
@posva When you have one async component it will be easy to handle it, but when you have more than one async components it will be difficult 😢.
@yyx990803 @posva Thanks guys! Currently I have found a workaround and if I create really common solution I will post here.