Skip to content

Commit 2de5cdd

Browse files
committed
feat(runtime-core): add manual flushing mode
1 parent a6eebba commit 2de5cdd

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

packages/runtime-core/src/scheduler.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,12 @@ export function switchToAuto(): void {
145145
}
146146
}
147147

148-
flushIndex = 0
148+
flushIndex = -1
149149
queue.length = 0
150150

151151
flushPostFlushCbs(seen)
152152

153153
endFlush()
154-
isFlushing = false
155154
currentFlushPromise = null
156155
// some postFlushCb queued jobs!
157156
// keep flushing until it drains.
@@ -161,9 +160,8 @@ export function switchToAuto(): void {
161160
auto = true
162161
}
163162
} else {
164-
flushIndex = 0
163+
flushIndex = -1
165164
endFlush()
166-
isFlushing = false
167165
currentFlushPromise = null
168166
activePostFlushCbs = null
169167
postFlushIndex = 0
@@ -173,7 +171,6 @@ export function switchToAuto(): void {
173171

174172
export function switchToManual(): void {
175173
controllers++
176-
queueFlush()
177174
auto = false
178175
}
179176

@@ -393,7 +390,7 @@ function flushJobs(seen?: CountMap) {
393390
: NOOP
394391

395392
try {
396-
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
393+
for (flushIndex = -1; flushIndex < queue.length; flushIndex++) {
397394
const job = queue[flushIndex]
398395
if (job && !(job.flags! & SchedulerJobFlags.DISPOSED)) {
399396
if (__DEV__ && check(job)) {

0 commit comments

Comments
 (0)