Skip to content

Commit

Permalink
revert for the write case
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed May 26, 2024
1 parent 0ab0a99 commit cfd7b88
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/vanilla/store2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,12 @@ export const createStore = (): Store => {
throw new Error('atom not writable')
}
const aState = getAtomState(a)
const prevEpochNumber = aState.n
const hasPrevValue = 'v' in aState
const prevValue = aState.v
const v = args[0] as V
setAtomStateValueOrPromise(a, aState, v)
mountDependencies(pending, a, aState)
if (prevEpochNumber !== aState.n) {
if (!hasPrevValue || !Object.is(prevValue, aState.v)) {
addPendingAtom(pending, a, aState)
recomputeDependents(pending, a)
}
Expand Down Expand Up @@ -679,10 +680,11 @@ export const createStore = (): Store => {
for (const [atom, value] of values) {
if (hasInitialValue(atom)) {
const aState = getAtomState(atom)
const prevEpochNumber = aState.n
const hasPrevValue = 'v' in aState
const prevValue = aState.v
setAtomStateValueOrPromise(atom, aState, value)
mountDependencies(pending, atom, aState)
if (prevEpochNumber !== aState.n) {
if (!hasPrevValue || !Object.is(prevValue, aState.v)) {
addPendingAtom(pending, atom, aState)
recomputeDependents(pending, atom)
}
Expand Down

0 comments on commit cfd7b88

Please sign in to comment.