From 77027ae52554f5ca980a736aab2179bd7543497b Mon Sep 17 00:00:00 2001 From: daishi Date: Sat, 24 Feb 2024 00:20:42 +0900 Subject: [PATCH] refactor --- src/vanilla/store.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vanilla/store.ts b/src/vanilla/store.ts index 1e3093808f..b20722e92d 100644 --- a/src/vanilla/store.ts +++ b/src/vanilla/store.ts @@ -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! })) } @@ -723,7 +723,9 @@ export const createStore = () => { }) } - const flushPending = (pendingAtoms: AnyAtom[]): void | Set => { + const flushPending = ( + pendingAtoms: AnyAtom[] | Set, + ): void | Set => { let flushed: Set if (import.meta.env?.MODE !== 'production') { flushed = new Set() @@ -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! }), )