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.

Add some new lifecycle hooks for components

See original GitHub issue

Hello,

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

github_iconTop GitHub Comments

2reactions
mdreizincommented, Nov 11, 2016

@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 😢.

1reaction
mdreizincommented, Jan 19, 2017

@yyx990803 @posva Thanks guys! Currently I have found a workaround and if I create really common solution I will post here.

Read more comments on GitHub >

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

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