Skip to content

Commit

Permalink
Revert "Debounce dispatched state diffs"
Browse files Browse the repository at this point in the history
This reverts commit bed16a9.
  • Loading branch information
jagodarybacka committed Jul 24, 2023
1 parent 2dea1ca commit b8d911b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 58 deletions.
24 changes: 3 additions & 21 deletions background/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,30 +508,12 @@ export default class Main extends BaseService<never> {
// Start up the redux store and set it up for proxying.
this.store = initializeStore(savedReduxState, this)

const queueUpdate = debounce(
(lastState, newState, updateFn) => {
if (lastState === newState) {
return
}

const diff = deepDiff(lastState, newState)

if (diff !== undefined) {
updateFn(newState, [diff])
}
},
30,
{ maxWait: 30, trailing: true }
)

wrapStore(this.store, {
serializer: encodeJSON,
deserializer: decodeJSON,
diffStrategy: (oldObj, newObj, forceUpdate) => {
queueUpdate(oldObj, newObj, forceUpdate)

// Return no diffs as we're manually handling these inside `queueUpdate`
return []
diffStrategy: (oldObj, newObj) => {
const diffWrapper = deepDiff(oldObj, newObj)
return diffWrapper === undefined ? [] : [diffWrapper]
},
dispatchResponder: async (
dispatchResult: Promise<unknown>,
Expand Down
Loading

0 comments on commit b8d911b

Please sign in to comment.