Skip to content

Commit

Permalink
chore(reactivity-signal): more test cases and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dntzhang committed May 18, 2024
1 parent b74fff9 commit 4164d73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/reactive-signal/src/reactivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ export function runBatch(): void {
while (batchQueue.size) {
const fn = batchQueue.values().next().value
if (fn) {
// fn 函数内部的 set 还是触发 batch,导致 batchQueue.size 增加 ,所以上面需要判断 batchQueue.size === 1
fn()
// 移除直到 batchQueue 清空
batchQueue.delete(fn)
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/reactive-signal/test/reactivity.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,6 @@ describe('batch', () => {
testSignal.value = 40
})
expect(effectTimes).toBe(2)
expect(testSignal.value).toBe(40)
})
})

0 comments on commit 4164d73

Please sign in to comment.