Skip to content

Commit

Permalink
refactor: following up #2912
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Jan 7, 2025
1 parent 9861266 commit fc1227a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/vanilla/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ const patchPromiseForCancelability = <T>(promise: PromiseLike<T>) => {
}

const isPromiseLike = (
x: unknown,
): x is PromiseLike<unknown> & { onCancel?: (fn: CancelHandler) => void } =>
typeof (x as any)?.then === 'function'
p: unknown,
): p is PromiseLike<unknown> & { onCancel?: (fn: CancelHandler) => void } =>
typeof (p as any)?.then === 'function'

/**
* State tracked for mounted atoms. An atom is considered "mounted" if it has a
Expand Down Expand Up @@ -440,8 +440,6 @@ const buildStore = (...storeArgs: StoreArgs): Store => {
returnAtomValue(readAtomState(undefined, atom))

const getMountedOrBatchDependents = <Value>(
batch: Batch,
atom: Atom<Value>,
atomState: AtomState<Value>,
): Map<AnyAtom, AtomState> => {
const dependents = new Map<AnyAtom, AtomState>()
Expand Down Expand Up @@ -501,7 +499,7 @@ const buildStore = (...storeArgs: StoreArgs): Store => {
}
visiting.add(a)
// Push unvisited dependents onto the stack
for (const [d, s] of getMountedOrBatchDependents(batch, a, aState)) {
for (const [d, s] of getMountedOrBatchDependents(aState)) {
if (a !== d && !visiting.has(d)) {
stack.push([d, s])
}
Expand Down

0 comments on commit fc1227a

Please sign in to comment.