Home / Function/ lifecycleMixin() — vue Function Reference

lifecycleMixin() — vue Function Reference

Architecture documentation for the lifecycleMixin() function in lifecycle.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  1edb3174_323d_290c_a67e_82eeac5c460f["lifecycleMixin()"]
  dc2699e8_e9c4_3f79_1c12_30d06eb6e4ef["setActiveInstance()"]
  1edb3174_323d_290c_a67e_82eeac5c460f -->|calls| dc2699e8_e9c4_3f79_1c12_30d06eb6e4ef
  14b99303_c554_b866_9055_da13a09ced22["update()"]
  1edb3174_323d_290c_a67e_82eeac5c460f -->|calls| 14b99303_c554_b866_9055_da13a09ced22
  a7fb5d54_f5e0_5d73_5f6a_96e6c47acbeb["callHook()"]
  1edb3174_323d_290c_a67e_82eeac5c460f -->|calls| a7fb5d54_f5e0_5d73_5f6a_96e6c47acbeb
  f56d0707_2860_9029_75e6_bec7ce6df815["remove()"]
  1edb3174_323d_290c_a67e_82eeac5c460f -->|calls| f56d0707_2860_9029_75e6_bec7ce6df815
  4a222c5c_d85c_6c90_508b_adee198fde38["stop()"]
  1edb3174_323d_290c_a67e_82eeac5c460f -->|calls| 4a222c5c_d85c_6c90_508b_adee198fde38
  d3a9b0b7_99ab_b5bb_091e_532513c272a1["off()"]
  1edb3174_323d_290c_a67e_82eeac5c460f -->|calls| d3a9b0b7_99ab_b5bb_091e_532513c272a1
  style 1edb3174_323d_290c_a67e_82eeac5c460f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/instance/lifecycle.ts lines 62–145

export function lifecycleMixin(Vue: typeof Component) {
  Vue.prototype._update = function (vnode: VNode, hydrating?: boolean) {
    const vm: Component = this
    const prevEl = vm.$el
    const prevVnode = vm._vnode
    const restoreActiveInstance = setActiveInstance(vm)
    vm._vnode = vnode
    // Vue.prototype.__patch__ is injected in entry points
    // based on the rendering backend used.
    if (!prevVnode) {
      // initial render
      vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */)
    } else {
      // updates
      vm.$el = vm.__patch__(prevVnode, vnode)
    }
    restoreActiveInstance()
    // update __vue__ reference
    if (prevEl) {
      prevEl.__vue__ = null
    }
    if (vm.$el) {
      vm.$el.__vue__ = vm
    }
    // if parent is an HOC, update its $el as well
    let wrapper: Component | undefined = vm
    while (
      wrapper &&
      wrapper.$vnode &&
      wrapper.$parent &&
      wrapper.$vnode === wrapper.$parent._vnode
    ) {
      wrapper.$parent.$el = wrapper.$el
      wrapper = wrapper.$parent
    }
    // updated hook is called by the scheduler to ensure that children are
    // updated in a parent's updated hook.
  }

  Vue.prototype.$forceUpdate = function () {
    const vm: Component = this
    if (vm._watcher) {
      vm._watcher.update()
    }
  }

  Vue.prototype.$destroy = function () {
    const vm: Component = this
    if (vm._isBeingDestroyed) {
      return
    }
    callHook(vm, 'beforeDestroy')
    vm._isBeingDestroyed = true
    // remove self from parent
    const parent = vm.$parent
    if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
      remove(parent.$children, vm)
    }
    // teardown scope. this includes both the render watcher and other
    // watchers created
    vm._scope.stop()
    // remove reference from data ob
    // frozen object may not have observer.
    if (vm._data.__ob__) {
      vm._data.__ob__.vmCount--
    }
    // call the last hook...
    vm._isDestroyed = true
    // invoke destroy hooks on current rendered tree
    vm.__patch__(vm._vnode, null)
    // fire destroyed hook
    callHook(vm, 'destroyed')
    // turn off all instance listeners.
    vm.$off()
    // remove __vue__ reference
    if (vm.$el) {
      vm.$el.__vue__ = null
    }
    // release circular reference (#6759)
    if (vm.$vnode) {
      vm.$vnode.parent = null
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does lifecycleMixin() do?
lifecycleMixin() is a function in the vue codebase.
What does lifecycleMixin() call?
lifecycleMixin() calls 6 function(s): callHook, off, remove, setActiveInstance, stop, update.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free