fix(scheduler): handle preFlush cb queued inside postFlush cb
fix #3806
This commit is contained in:
parent
e8ddf86080
commit
b57e995edd
@ -230,6 +230,16 @@ describe('scheduler', () => {
|
|||||||
await nextTick()
|
await nextTick()
|
||||||
expect(calls).toEqual(['cb1', 'cb2', 'job1'])
|
expect(calls).toEqual(['cb1', 'cb2', 'job1'])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #3806
|
||||||
|
it('queue preFlushCb inside postFlushCb', async () => {
|
||||||
|
const cb = jest.fn()
|
||||||
|
queuePostFlushCb(() => {
|
||||||
|
queuePreFlushCb(cb)
|
||||||
|
})
|
||||||
|
await nextTick()
|
||||||
|
expect(cb).toHaveBeenCalled()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('queuePostFlushCb', () => {
|
describe('queuePostFlushCb', () => {
|
||||||
|
@ -260,7 +260,11 @@ function flushJobs(seen?: CountMap) {
|
|||||||
currentFlushPromise = null
|
currentFlushPromise = null
|
||||||
// some postFlushCb queued jobs!
|
// some postFlushCb queued jobs!
|
||||||
// keep flushing until it drains.
|
// keep flushing until it drains.
|
||||||
if (queue.length || pendingPostFlushCbs.length) {
|
if (
|
||||||
|
queue.length ||
|
||||||
|
pendingPreFlushCbs.length ||
|
||||||
|
pendingPostFlushCbs.length
|
||||||
|
) {
|
||||||
flushJobs(seen)
|
flushJobs(seen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user