Home / Function/ waitForUpdate() — vue Function Reference

waitForUpdate() — vue Function Reference

Architecture documentation for the waitForUpdate() function in wait-for-update.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  59a23fc4_ad00_7532_f437_830d9baa4c59["waitForUpdate()"]
  49cc4478_fbda_0e63_b1b3_7caa96b807ac["timeout()"]
  59a23fc4_ad00_7532_f437_830d9baa4c59 -->|calls| 49cc4478_fbda_0e63_b1b3_7caa96b807ac
  style 59a23fc4_ad00_7532_f437_830d9baa4c59 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

test/helpers/wait-for-update.ts lines 21–75

const waitForUpdate = (initialCb: Job) => {
  let end
  const queue: Job[] = initialCb ? [initialCb] : []

  function shift() {
    const job = queue.shift()
    if (queue.length) {
      let hasError = false
      try {
        job!.wait ? job!(shift) : job!()
      } catch (e) {
        hasError = true
        const done = queue[queue.length - 1]
        if (done && done.fail) {
          done.fail(e)
        }
      }
      if (!hasError && !job!.wait) {
        if (queue.length) {
          Vue.nextTick(shift)
        }
      }
    } else if (job && (job.fail || job === end)) {
      job() // done
    }
  }

  Vue.nextTick(() => {
    if (!queue.length || (!end && !queue[queue.length - 1]!.fail)) {
      throw new Error('waitForUpdate chain is missing .then(done)')
    }
    shift()
  })

  const chainer = {
    then: nextCb => {
      queue.push(nextCb)
      return chainer
    },
    thenWaitFor: wait => {
      if (typeof wait === 'number') {
        wait = timeout(wait)
      }
      wait.wait = true
      queue.push(wait)
      return chainer
    },
    end: endFn => {
      queue.push(endFn)
      end = endFn
    }
  }

  return chainer
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does waitForUpdate() do?
waitForUpdate() is a function in the vue codebase.
What does waitForUpdate() call?
waitForUpdate() calls 1 function(s): timeout.

Analyze Your Own Codebase

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

Try Supermodel Free