Skip to content

Commit

Permalink
perf(setData): setData执行时机改回使用宏任务
Browse files Browse the repository at this point in the history
  • Loading branch information
yushijie1 committed Nov 6, 2024
1 parent 6ed8d05 commit 6803490
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions packages/taro-runtime/src/dom/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,8 @@ export class TaroRootElement extends TaroElement {
}

public scheduleTask(fn: TFunc) {
if (isFunction(Promise)) {
Promise.resolve()
.then(fn)
.catch((error) => {
setTimeout(() => {
throw error
})
})
} else {
setTimeout(fn)
}
// 这里若使用微任务可略微提前setData的执行时机,但在部分场景下可能会出现连续setData两次,造成更大的性能问题
setTimeout(fn)
}

public enqueueUpdate (payload: UpdatePayload): void {
Expand Down

0 comments on commit 6803490

Please sign in to comment.