Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben-Arushanyan committed Oct 3, 2023
1 parent 5c05c0c commit 8a35048
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ class Store {
}

subscribeSelector = (selector, cb) => {
let prevValue = selector(this.prevState)
return this.subscribe(() => {
const prevValue = selector(this.prevState)
const newValue = selector(this.state)
if (!eq(newValue, prevValue)) {
cb(newValue, prevValue);
const prev = prevValue
prevValue = newValue
cb(newValue, prev);
}
})
}
Expand Down

0 comments on commit 8a35048

Please sign in to comment.