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 03a530f commit 563132b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/reactivity/src/dep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class Dep {
}
}
}
for (let link = this.subsHead; link; link = link.nextSub) {
for (let link = this.subs; link; link = link.prevSub) {
link.sub.notify()
}
} finally {
Expand Down
11 changes: 10 additions & 1 deletion packages/runtime-core/src/apiWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ 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 @@ -395,7 +397,14 @@ function doWatch(
let scheduler: EffectScheduler
if (flush === 'sync') {
effect.flags |= EffectFlags.NO_BATCH
scheduler = job as any // the scheduler function gets called directly
syncJobs.push(job)
scheduler = () => {
const job = syncJobs.shift()
if (job) {
syncJobs.push(job)
job()
}
} // the scheduler function gets called directly in reverse-order
} else if (flush === 'post') {
scheduler = () => queuePostRenderEffect(job, instance && instance.suspense)
} else {
Expand Down

0 comments on commit 563132b

Please sign in to comment.