Home / Function/ callHook() — vue Function Reference

callHook() — vue Function Reference

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

Function typescript VueCore Instance calls 2 called by 7

Entity Profile

Dependency Diagram

graph TD
  77ac8989_609a_4755_79eb_0403c1cc7788["callHook()"]
  d937f76e_061f_a631_9587_336503c9a15c["lifecycle.ts"]
  77ac8989_609a_4755_79eb_0403c1cc7788 -->|defined in| d937f76e_061f_a631_9587_336503c9a15c
  27e71f35_12fd_58cc_25d7_c5686da5aaf6["initMixin()"]
  27e71f35_12fd_58cc_25d7_c5686da5aaf6 -->|calls| 77ac8989_609a_4755_79eb_0403c1cc7788
  5ebc50a8_91d4_fca0_61db_b1eb7c6dc6ca["lifecycleMixin()"]
  5ebc50a8_91d4_fca0_61db_b1eb7c6dc6ca -->|calls| 77ac8989_609a_4755_79eb_0403c1cc7788
  4608cf7a_77c1_65d7_34bb_dbc4ea050d61["mountComponent()"]
  4608cf7a_77c1_65d7_34bb_dbc4ea050d61 -->|calls| 77ac8989_609a_4755_79eb_0403c1cc7788
  428cbd6d_51c5_fed9_65af_f319e424b217["activateChildComponent()"]
  428cbd6d_51c5_fed9_65af_f319e424b217 -->|calls| 77ac8989_609a_4755_79eb_0403c1cc7788
  8d2d9489_7b69_4b25_92ee_497afbc2fc3b["deactivateChildComponent()"]
  8d2d9489_7b69_4b25_92ee_497afbc2fc3b -->|calls| 77ac8989_609a_4755_79eb_0403c1cc7788
  bcb31f89_65da_2298_fd9e_3da8b97459f3["callUpdatedHooks()"]
  bcb31f89_65da_2298_fd9e_3da8b97459f3 -->|calls| 77ac8989_609a_4755_79eb_0403c1cc7788
  598b2801_d8c2_3e04_0530_7ded414e83de["componentVNodeHooks.insert()"]
  598b2801_d8c2_3e04_0530_7ded414e83de -->|calls| 77ac8989_609a_4755_79eb_0403c1cc7788
  d9fae33f_7845_7289_de16_bee11c7f60e1["pushTarget()"]
  77ac8989_609a_4755_79eb_0403c1cc7788 -->|calls| d9fae33f_7845_7289_de16_bee11c7f60e1
  e4823f37_5db2_5310_aa9c_5b3593b02b07["popTarget()"]
  77ac8989_609a_4755_79eb_0403c1cc7788 -->|calls| e4823f37_5db2_5310_aa9c_5b3593b02b07
  style 77ac8989_609a_4755_79eb_0403c1cc7788 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, defined in src/core/instance/lifecycle.ts.
Where is callHook() defined?
callHook() is defined in src/core/instance/lifecycle.ts at line 394.
What does callHook() call?
callHook() calls 2 function(s): popTarget, pushTarget.
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