Skip to content

Commit

Permalink
fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Jan 5, 2025
1 parent 2f26b07 commit a0402eb
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions tests/vanilla/effect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Ref = {
inProgress: number
isRefreshing: number
epoch: number
cleanup?: Cleanup | void
cleanup?: Cleanup | undefined
error?: unknown
}

Expand Down Expand Up @@ -52,21 +52,22 @@ function syncEffect(effect: Effect): Atom<void> {
try {
ref.cleanup?.()
const deps = new Set<AnyAtom>()
ref.cleanup = effect(
(a) => {
deps.add(a)
return ref.get!(a)
},
(a, ...args) => {
try {
++ref.inProgress
return store.set(a, ...args)
} finally {
deps.forEach(ref.get!)
--ref.inProgress
}
},
)
ref.cleanup =
effect(
(a) => {
deps.add(a)
return ref.get!(a)
},
(a, ...args) => {
try {
++ref.inProgress
return store.set(a, ...args)
} finally {
deps.forEach(ref.get!)
--ref.inProgress
}
},
) || undefined
} catch (e) {
ref.error = e
// FIXME no test case that requires this refreshing
Expand Down

0 comments on commit a0402eb

Please sign in to comment.