国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

vue.js源代碼core scedule.js學習筆記

2019-11-19 16:11:17
字體:
來源:轉載
供稿:網友

vue.js 源代碼學習筆記 core scedule.js,供大家參考,具體內容如下

/* @flow */import type Watcher from './watcher'import config from '../config'import { callHook } from '../instance/lifecycle'import { warn, nextTick, devtools} from '../util/index'const queue: Array<Watcher> = []let has: { [key: number]: ?true } = {}let circular: { [key: number]: number } = {}let waiting = falselet flushing = falselet index = 0/** * Reset the scheduler's state. */function resetSchedulerState () { queue.length = 0 has = {} if (process.env.NODE_ENV !== 'production') { circular = {} } waiting = flushing = false}/** * Flush both queues and run the watchers. */function flushSchedulerQueue () { flushing = true let watcher, id, vm // 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((a, b) => a.id - b.id) // 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] id = watcher.id has[id] = null watcher.run() // in dev build, check and stop circular updates. if (process.env.NODE_ENV !== 'production' && has[id] != null) {  circular[id] = (circular[id] || 0) + 1  if (circular[id] > config._maxUpdateCount) {  warn(   'You may have an infinite update loop ' + (   watcher.user    ? `in watcher with expression "${watcher.expression}"`    : `in a component render function.`   ),   watcher.vm  )  break  } } } // reset scheduler before updated hook called const oldQueue = queue.slice() resetSchedulerState() // call updated hooks index = oldQueue.length while (index--) { watcher = oldQueue[index] vm = watcher.vm if (vm._watcher === watcher && vm._isMounted) {  callHook(vm, 'updated') } } // devtool hook /* istanbul ignore if */ if (devtools && config.devtools) { devtools.emit('flush') }}/** * Push a watcher into the watcher queue. * Jobs with duplicate IDs will be skipped unless it's * pushed when the queue is being flushed. */export function queueWatcher (watcher: Watcher) { const id = watcher.id if (has[id] == null) { has[id] = true if (!flushing) {  queue.push(watcher) } else {  // if already flushing, splice the watcher based on its id  // if already past its id, it will be run next immediately.  let i = queue.length - 1  while (i >= 0 && queue[i].id > watcher.id) {  i--  }  queue.splice(Math.max(i, index) + 1, 0, watcher) } // queue the flush if (!waiting) {  waiting = true  nextTick(flushSchedulerQueue) } }}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 抚顺县| 陇西县| 台北县| 吐鲁番市| 襄樊市| 松江区| 武宁县| 三江| 来宾市| 岢岚县| 吴江市| 舟曲县| 巴里| 自贡市| 玛多县| 嘉义县| 楚雄市| 衡东县| 钦州市| 长丰县| 囊谦县| 淮北市| 莲花县| 昭觉县| 吉木萨尔县| 望奎县| 儋州市| 崇阳县| 庄浪县| 泽普县| 昌平区| 桃园市| 库车县| 平罗县| 松潘县| 黄浦区| 休宁县| 南通市| 延庆县| 特克斯县| 泽库县|