Skip to content

sync

javascript
// sync 用于控制回调是否同步触发,在 update 时判断一下 this.sync 是否为真,为真就手
// 动调用 this.run() 执行 user watcher 回调,实现同步触发。否则执行 queueWatcher,
// 异步触发。
update () {
  if (this.sync) {
    this.run() // 同步的 user watcher, 执行同步任务
  } else {
    queueWatcher(this)
  }
}