Skip to content

Commit

Permalink
atom.write getter does not add dependencies to dependents
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaskasky committed Nov 16, 2024
1 parent 0f05df8 commit 33615be
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/vanilla/store.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -896,3 +896,15 @@ it('throws falsy errors in onMount, onUnmount, and listeners', () => {
})
expect(() => store.set(c, 1)).toThrow('')
})

it('does not update dependencies when accessed with write get', () => {
const store = createStore()
const a = atom(0)
const bRead = vi.fn((get) => get(a))
const b = atom(bRead)

Check failure on line 904 in tests/vanilla/store.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (4.0.5)

Parameter 'get' implicitly has an 'any' type.

Check failure on line 904 in tests/vanilla/store.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (3.9.7)

Parameter 'get' implicitly has an 'any' type.

Check failure on line 904 in tests/vanilla/store.test.tsx

View workflow job for this annotation

GitHub Actions / test_matrix (3.8.3)

Parameter 'get' implicitly has an 'any' type.
const w = atom(null, (get) => get(b))
store.set(w)
bRead.mockClear()
store.set(a, 1)
expect(bRead).not.toHaveBeenCalled() // fails
})

0 comments on commit 33615be

Please sign in to comment.