Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Feb 23, 2024
1 parent 14f2da2 commit 77027ae
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/vanilla/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ export const createStore = () => {
): Result => {
pendingStack.push(new Set([atom]))
const result = writeAtomState(atom, ...args)
const flushed = flushPending(Array.from(pendingStack.pop()!))
const flushed = flushPending(pendingStack.pop()!)
if (import.meta.env?.MODE !== 'production') {
storeListenersRev2.forEach((l) => l({ type: 'write', flushed: flushed! }))
}
Expand Down Expand Up @@ -723,7 +723,9 @@ export const createStore = () => {
})
}

const flushPending = (pendingAtoms: AnyAtom[]): void | Set<AnyAtom> => {
const flushPending = (
pendingAtoms: AnyAtom[] | Set<AnyAtom>,
): void | Set<AnyAtom> => {
let flushed: Set<AnyAtom>
if (import.meta.env?.MODE !== 'production') {
flushed = new Set()
Expand Down Expand Up @@ -825,7 +827,7 @@ export const createStore = () => {
recomputeDependents(atom)
}
}
const flushed = flushPending(Array.from(pendingStack.pop()!))
const flushed = flushPending(pendingStack.pop()!)
storeListenersRev2.forEach((l) =>
l({ type: 'restore', flushed: flushed! }),
)
Expand Down

0 comments on commit 77027ae

Please sign in to comment.