Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: following up #2912 #2915

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Comment on lines +61 to +63
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A refactor to follow #2907.


/**
* 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
Loading