Home / Function/ callHook() — vue Function Reference

callHook() — vue Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  71c7a5aa_6619_7aea_6a94_630a0527f309["callHook()"]
  340c5746_ff29_c74c_9da5_50db2db76e5f["initMixin()"]
  340c5746_ff29_c74c_9da5_50db2db76e5f -->|calls| 71c7a5aa_6619_7aea_6a94_630a0527f309
  c645c33d_8908_2339_67bb_0680e222abf8["lifecycleMixin()"]
  c645c33d_8908_2339_67bb_0680e222abf8 -->|calls| 71c7a5aa_6619_7aea_6a94_630a0527f309
  0ab0a954_29ae_5663_de65_22e22ba6d0b0["mountComponent()"]
  0ab0a954_29ae_5663_de65_22e22ba6d0b0 -->|calls| 71c7a5aa_6619_7aea_6a94_630a0527f309
  3e7d2138_fd8b_c8fc_5bdd_a47787d28445["activateChildComponent()"]
  3e7d2138_fd8b_c8fc_5bdd_a47787d28445 -->|calls| 71c7a5aa_6619_7aea_6a94_630a0527f309
  18d51aec_8d26_a819_8f35_582a8499968c["deactivateChildComponent()"]
  18d51aec_8d26_a819_8f35_582a8499968c -->|calls| 71c7a5aa_6619_7aea_6a94_630a0527f309
  911c0742_8b4d_52ad_2f13_f18a8cc327ff["callUpdatedHooks()"]
  911c0742_8b4d_52ad_2f13_f18a8cc327ff -->|calls| 71c7a5aa_6619_7aea_6a94_630a0527f309
  f7b166da_430e_e05b_587f_4795e8e1a828["componentVNodeHooks.insert()"]
  f7b166da_430e_e05b_587f_4795e8e1a828 -->|calls| 71c7a5aa_6619_7aea_6a94_630a0527f309
  4a87a208_8bf5_28ff_be4d_8df11d928f69["pushTarget()"]
  71c7a5aa_6619_7aea_6a94_630a0527f309 -->|calls| 4a87a208_8bf5_28ff_be4d_8df11d928f69
  a35e1f2c_f506_afae_a250_ce07c24cd4c1["getCurrentScope()"]
  71c7a5aa_6619_7aea_6a94_630a0527f309 -->|calls| a35e1f2c_f506_afae_a250_ce07c24cd4c1
  f6cc67da_03fd_cbe1_8ffb_6aaf0358d6ae["setCurrentInstance()"]
  71c7a5aa_6619_7aea_6a94_630a0527f309 -->|calls| f6cc67da_03fd_cbe1_8ffb_6aaf0358d6ae
  f4e8b3e2_8a7c_515d_008b_d923c4dc677b["on()"]
  71c7a5aa_6619_7aea_6a94_630a0527f309 -->|calls| f4e8b3e2_8a7c_515d_008b_d923c4dc677b
  f933dbd4_cb05_cc5c_162b_7ab5e35d316d["popTarget()"]
  71c7a5aa_6619_7aea_6a94_630a0527f309 -->|calls| f933dbd4_cb05_cc5c_162b_7ab5e35d316d
  style 71c7a5aa_6619_7aea_6a94_630a0527f309 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/instance/lifecycle.ts lines 394–421

export function callHook(
  vm: Component,
  hook: string,
  args?: any[],
  setContext = true
) {
  // #7573 disable dep collection when invoking lifecycle hooks
  pushTarget()
  const prevInst = currentInstance
  const prevScope = getCurrentScope()
  setContext && setCurrentInstance(vm)
  const handlers = vm.$options[hook]
  const info = `${hook} hook`
  if (handlers) {
    for (let i = 0, j = handlers.length; i < j; i++) {
      invokeWithErrorHandling(handlers[i], vm, args || null, vm, info)
    }
  }
  if (vm._hasHookEvent) {
    vm.$emit('hook:' + hook)
  }
  if (setContext) {
    setCurrentInstance(prevInst)
    prevScope && prevScope.on()
  }

  popTarget()
}

Domain

Subdomains

Frequently Asked Questions

What does callHook() do?
callHook() is a function in the vue codebase.
What does callHook() call?
callHook() calls 5 function(s): getCurrentScope, on, popTarget, pushTarget, setCurrentInstance.
What calls callHook()?
callHook() is called by 7 function(s): activateChildComponent, callUpdatedHooks, componentVNodeHooks.insert, deactivateChildComponent, initMixin, lifecycleMixin, mountComponent.

Analyze Your Own Codebase

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

Try Supermodel Free