Home / Function/ flushSchedulerQueue() — vue Function Reference

flushSchedulerQueue() — vue Function Reference

Architecture documentation for the flushSchedulerQueue() function in scheduler.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  5f88c922_50d0_318e_0c71_29334294af47["flushSchedulerQueue()"]
  ba3e2e94_ad22_f194_419c_8e274feb8fdd["queueWatcher()"]
  ba3e2e94_ad22_f194_419c_8e274feb8fdd -->|calls| 5f88c922_50d0_318e_0c71_29334294af47
  8d906bf5_d820_c7a4_0ad9_3bc66684fb10["getNow()"]
  5f88c922_50d0_318e_0c71_29334294af47 -->|calls| 8d906bf5_d820_c7a4_0ad9_3bc66684fb10
  eb15026c_5696_e629_0e8f_4bc0a98f7d98["run()"]
  5f88c922_50d0_318e_0c71_29334294af47 -->|calls| eb15026c_5696_e629_0e8f_4bc0a98f7d98
  b0dbf752_3594_560e_a5a4_5a6563bda57a["resetSchedulerState()"]
  5f88c922_50d0_318e_0c71_29334294af47 -->|calls| b0dbf752_3594_560e_a5a4_5a6563bda57a
  ec2abe38_2f10_389c_6777_d109af8942d6["callActivatedHooks()"]
  5f88c922_50d0_318e_0c71_29334294af47 -->|calls| ec2abe38_2f10_389c_6777_d109af8942d6
  cc03eaa1_014d_1aa1_3d2e_3e3ec49b0a7a["callUpdatedHooks()"]
  5f88c922_50d0_318e_0c71_29334294af47 -->|calls| cc03eaa1_014d_1aa1_3d2e_3e3ec49b0a7a
  6718cf56_a4af_5db8_36ad_7b7fa60c0584["cleanupDeps()"]
  5f88c922_50d0_318e_0c71_29334294af47 -->|calls| 6718cf56_a4af_5db8_36ad_7b7fa60c0584
  style 5f88c922_50d0_318e_0c71_29334294af47 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/observer/scheduler.ts lines 74–131

function flushSchedulerQueue() {
  currentFlushTimestamp = getNow()
  flushing = true
  let watcher, id

  // Sort queue before flush.
  // This ensures that:
  // 1. Components are updated from parent to child. (because parent is always
  //    created before the child)
  // 2. A component's user watchers are run before its render watcher (because
  //    user watchers are created before the render watcher)
  // 3. If a component is destroyed during a parent component's watcher run,
  //    its watchers can be skipped.
  queue.sort(sortCompareFn)

  // do not cache length because more watchers might be pushed
  // as we run existing watchers
  for (index = 0; index < queue.length; index++) {
    watcher = queue[index]
    if (watcher.before) {
      watcher.before()
    }
    id = watcher.id
    has[id] = null
    watcher.run()
    // in dev build, check and stop circular updates.
    if (__DEV__ && has[id] != null) {
      circular[id] = (circular[id] || 0) + 1
      if (circular[id] > MAX_UPDATE_COUNT) {
        warn(
          'You may have an infinite update loop ' +
            (watcher.user
              ? `in watcher with expression "${watcher.expression}"`
              : `in a component render function.`),
          watcher.vm
        )
        break
      }
    }
  }

  // keep copies of post queues before resetting state
  const activatedQueue = activatedChildren.slice()
  const updatedQueue = queue.slice()

  resetSchedulerState()

  // call component updated and activated hooks
  callActivatedHooks(activatedQueue)
  callUpdatedHooks(updatedQueue)
  cleanupDeps()

  // devtool hook
  /* istanbul ignore if */
  if (devtools && config.devtools) {
    devtools.emit('flush')
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does flushSchedulerQueue() do?
flushSchedulerQueue() is a function in the vue codebase.
What does flushSchedulerQueue() call?
flushSchedulerQueue() calls 6 function(s): callActivatedHooks, callUpdatedHooks, cleanupDeps, getNow, resetSchedulerState, run.
What calls flushSchedulerQueue()?
flushSchedulerQueue() is called by 1 function(s): queueWatcher.

Analyze Your Own Codebase

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

Try Supermodel Free