MCPcopy
hub / github.com/vuejs/core / flushPostFlushCbs

Function flushPostFlushCbs

packages/runtime-core/src/scheduler.ts:173–209  ·  view source on GitHub ↗
(seen?: CountMap)

Source from the content-addressed store, hash-verified

171}
172
173export function flushPostFlushCbs(seen?: CountMap): void {
174 if (pendingPostFlushCbs.length) {
175 const deduped = [...new Set(pendingPostFlushCbs)].sort(
176 (a, b) => getId(a) - getId(b),
177 )
178 pendingPostFlushCbs.length = 0
179
180 // #1947 already has active queue, nested flushPostFlushCbs call
181 if (activePostFlushCbs) {
182 activePostFlushCbs.push(...deduped)
183 return
184 }
185
186 activePostFlushCbs = deduped
187 if (__DEV__) {
188 seen = seen || new Map()
189 }
190
191 for (
192 postFlushIndex = 0;
193 postFlushIndex < activePostFlushCbs.length;
194 postFlushIndex++
195 ) {
196 const cb = activePostFlushCbs[postFlushIndex]
197 if (__DEV__ && checkRecursiveUpdates(seen!, cb)) {
198 continue
199 }
200 if (cb.flags! & SchedulerJobFlags.ALLOW_RECURSE) {
201 cb.flags! &= ~SchedulerJobFlags.QUEUED
202 }
203 if (!(cb.flags! & SchedulerJobFlags.DISPOSED)) cb()
204 cb.flags! &= ~SchedulerJobFlags.QUEUED
205 }
206 activePostFlushCbs = null
207 postFlushIndex = 0
208 }
209}
210
211const getId = (job: SchedulerJob): number =>
212 job.id == null ? (job.flags! & SchedulerJobFlags.PRE ? -1 : Infinity) : job.id

Callers 5

renderFunction · 0.90
hydrateFunction · 0.90
queueAndFlushFunction · 0.90
scheduler.spec.tsFile · 0.90
flushJobsFunction · 0.85

Calls 4

checkRecursiveUpdatesFunction · 0.85
cbFunction · 0.85
getIdFunction · 0.70
pushMethod · 0.65

Tested by 1

queueAndFlushFunction · 0.72