Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhe141 committed Aug 12, 2024
1 parent a650c5f commit 5c2bc23
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class ReactiveEffect<T = any>
) {
return
}
if (this.flags & EffectFlags.NO_BATCH) {
if (this.flags & EffectFlags.NO_BATCH && !batchDepth) {
return this.trigger()
}
if (!(this.flags & EffectFlags.NOTIFIED)) {
Expand Down Expand Up @@ -267,6 +267,7 @@ export function endBatch(): void {
return
}

batchDepth--
let error: unknown
while (batchedEffect) {
let e: ReactiveEffect | undefined = batchedEffect
Expand All @@ -286,7 +287,6 @@ export function endBatch(): void {
}
}

batchDepth--
if (error) throw error
}

Expand Down
12 changes: 2 additions & 10 deletions packages/runtime-core/src/apiWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ export function watch<T = any, Immediate extends Readonly<boolean> = false>(
return doWatch(source as any, cb, options)
}

const syncJobs: SchedulerJob[] = []

function doWatch(
source: WatchSource | WatchSource[] | WatchEffect | object,
cb: WatchCallback | null,
Expand Down Expand Up @@ -397,14 +395,8 @@ function doWatch(
let scheduler: EffectScheduler
if (flush === 'sync') {
effect.flags |= EffectFlags.NO_BATCH
syncJobs.push(job)
scheduler = () => {
const job = syncJobs.shift()
if (job) {
syncJobs.push(job)
job()
}
} // the scheduler function gets called directly in reverse-order

scheduler = job as any
} else if (flush === 'post') {
scheduler = () => queuePostRenderEffect(job, instance && instance.suspense)
} else {
Expand Down

0 comments on commit 5c2bc23

Please sign in to comment.