* Push a watcher into the watcher queue. * Jobs with duplicate IDs will be skipped unless it's * pushed when the queue is being flushed.
(watcher)
| 2377 | * pushed when the queue is being flushed. |
| 2378 | */ |
| 2379 | function queueWatcher (watcher) { |
| 2380 | var id = watcher.id; |
| 2381 | if (has[id] == null) { |
| 2382 | has[id] = true; |
| 2383 | if (!flushing) { |
| 2384 | queue.push(watcher); |
| 2385 | } else { |
| 2386 | // if already flushing, splice the watcher based on its id |
| 2387 | // if already past its id, it will be run next immediately. |
| 2388 | var i = queue.length - 1; |
| 2389 | while (i >= 0 && queue[i].id > watcher.id) { |
| 2390 | i--; |
| 2391 | } |
| 2392 | queue.splice(Math.max(i, index) + 1, 0, watcher); |
| 2393 | } |
| 2394 | // queue the flush |
| 2395 | if (!waiting) { |
| 2396 | waiting = true; |
| 2397 | nextTick(flushSchedulerQueue); |
| 2398 | } |
| 2399 | } |
| 2400 | } |
| 2401 | |
| 2402 | /* */ |
| 2403 |