MCPcopy Create free account
hub / github.com/TruthHun/BookStack / flushSchedulerQueue

Function flushSchedulerQueue

static/vuejs/vue.esm.js:2309–2366  ·  view source on GitHub ↗

* Flush both queues and run the watchers.

()

Source from the content-addressed store, hash-verified

2307 * Flush both queues and run the watchers.
2308 */
2309function flushSchedulerQueue () {
2310 flushing = true;
2311 var watcher, id, vm;
2312
2313 // Sort queue before flush.
2314 // This ensures that:
2315 // 1. Components are updated from parent to child. (because parent is always
2316 // created before the child)
2317 // 2. A component's user watchers are run before its render watcher (because
2318 // user watchers are created before the render watcher)
2319 // 3. If a component is destroyed during a parent component's watcher run,
2320 // its watchers can be skipped.
2321 queue.sort(function (a, b) { return a.id - b.id; });
2322
2323 // do not cache length because more watchers might be pushed
2324 // as we run existing watchers
2325 for (index = 0; index < queue.length; index++) {
2326 watcher = queue[index];
2327 id = watcher.id;
2328 has[id] = null;
2329 watcher.run();
2330 // in dev build, check and stop circular updates.
2331 if (process.env.NODE_ENV !== 'production' && has[id] != null) {
2332 circular[id] = (circular[id] || 0) + 1;
2333 if (circular[id] > config._maxUpdateCount) {
2334 warn(
2335 'You may have an infinite update loop ' + (
2336 watcher.user
2337 ? ("in watcher with expression \"" + (watcher.expression) + "\"")
2338 : "in a component render function."
2339 ),
2340 watcher.vm
2341 );
2342 break
2343 }
2344 }
2345 }
2346
2347 // reset scheduler before updated hook called
2348 var oldQueue = queue.slice();
2349 resetSchedulerState();
2350
2351 // call updated hooks
2352 index = oldQueue.length;
2353 while (index--) {
2354 watcher = oldQueue[index];
2355 vm = watcher.vm;
2356 if (vm._watcher === watcher && vm._isMounted) {
2357 callHook(vm, 'updated');
2358 }
2359 }
2360
2361 // devtool hook
2362 /* istanbul ignore if */
2363 if (devtools && config.devtools) {
2364 devtools.emit('flush');
2365 }
2366}

Callers

nothing calls this directly

Calls 3

resetSchedulerStateFunction · 0.70
callHookFunction · 0.70
warnFunction · 0.50

Tested by

no test coverage detected