Skip to content

Commit 1bebe84

Browse files
committed
revert to default
1 parent 2de5cdd commit 1bebe84

File tree

1 file changed

+16
-62
lines changed

1 file changed

+16
-62
lines changed

packages/runtime-core/src/apiWatch.ts

Lines changed: 16 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ import {
88
type WatchSource,
99
watch as baseWatch,
1010
} from '@vue/reactivity'
11-
import {
12-
type SchedulerJob,
13-
SchedulerJobFlags,
14-
queueJob,
15-
queuePostFlushCb,
16-
} from './scheduler'
11+
import { type SchedulerJob, SchedulerJobFlags, queueJob } from './scheduler'
1712
import { EMPTY_OBJ, NOOP, extend, isFunction, isString } from '@vue/shared'
1813
import {
1914
type ComponentInternalInstance,
@@ -22,7 +17,7 @@ import {
2217
setCurrentInstance,
2318
} from './component'
2419
import { callWithAsyncErrorHandling } from './errorHandling'
25-
// import { queuePostRenderEffect } from './renderer'
20+
import { queuePostRenderEffect } from './renderer'
2621
import { warn } from './warning'
2722
import type { ObjectWatchOptionItem } from './componentOptions'
2823
import { useSSRContext } from './helpers/useSsrContext'
@@ -47,7 +42,7 @@ type MapSources<T, Immediate> = {
4742
}
4843

4944
export interface WatchEffectOptions extends DebuggerOptions {
50-
flush?: 'pre' | 'post' | 'sync' | 'insertion' | 'layout'
45+
flush?: 'pre' | 'post' | 'sync'
5146
}
5247

5348
export interface WatchOptions<Immediate = boolean> extends WatchEffectOptions {
@@ -86,32 +81,6 @@ export function watchSyncEffect(
8681
)
8782
}
8883

89-
export function watchInsertionEffect(
90-
effect: WatchEffect,
91-
options?: DebuggerOptions,
92-
): WatchHandle {
93-
return doWatch(
94-
effect,
95-
null,
96-
__DEV__
97-
? extend({}, options as any, { flush: 'insertion' })
98-
: { flush: 'insertion' },
99-
)
100-
}
101-
102-
export function watchLayoutEffect(
103-
effect: WatchEffect,
104-
options?: DebuggerOptions,
105-
): WatchHandle {
106-
return doWatch(
107-
effect,
108-
null,
109-
__DEV__
110-
? extend({}, options as any, { flush: 'layout' })
111-
: { flush: 'layout' },
112-
)
113-
}
114-
11584
export type MultiWatchSources = (WatchSource<unknown> | object)[]
11685

11786
// overload: single source + cb
@@ -223,35 +192,20 @@ function doWatch(
223192

224193
// scheduler
225194
let isPre = false
226-
switch (flush) {
227-
case 'post':
228-
case 'layout':
229-
case 'insertion':
230-
baseWatchOptions.scheduler = job => {
231-
const jobs = queuePostFlushCb(job)
232-
const instance = job.i
233-
if (instance) {
234-
for (let i = jobs.offset; i < jobs.offset + jobs.length; i++) {
235-
instance.queueEffect!(flush, i)
236-
}
237-
}
238-
}
239-
break
240-
case 'sync':
241-
break
242-
default:
243-
// default: 'pre'
244-
isPre = true
245-
baseWatchOptions.scheduler = (job, isFirstRun) => {
246-
if (isFirstRun) {
247-
job()
248-
} else {
249-
const instance = job.i
250-
const jobIndex = queueJob(job)
251-
if (instance) instance.queueEffect!('pre', jobIndex)
252-
}
195+
if (flush === 'post') {
196+
baseWatchOptions.scheduler = job => {
197+
queuePostRenderEffect(job, instance && instance.suspense)
198+
}
199+
} else if (flush !== 'sync') {
200+
// default: 'pre'
201+
isPre = true
202+
baseWatchOptions.scheduler = (job, isFirstRun) => {
203+
if (isFirstRun) {
204+
job()
205+
} else {
206+
queueJob(job)
253207
}
254-
break
208+
}
255209
}
256210

257211
baseWatchOptions.augmentJob = (job: SchedulerJob) => {

0 commit comments

Comments
 (0)