Skip to content

Commit

Permalink
Use throttle rather than debounce under the hood (#2)
Browse files Browse the repository at this point in the history
* Use throttle rather than debounce under the hood

* v1.0.1
  • Loading branch information
dpikt authored Aug 24, 2018
1 parent 607dbd6 commit 210009f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-sessions",
"version": "1.0.0",
"version": "1.0.1",
"description": "Redux action creators for storing session state",
"main": "lib/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/enhancer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { saveSessionState } from './persistenceHelpers'
import { debounce } from 'lodash'
import { throttle } from 'lodash'

const DEFAULT_DEBOUNCE_INTERVAL = 500

Expand All @@ -15,7 +15,7 @@ function enhancer ({ persist=true, debounceInterval=DEFAULT_DEBOUNCE_INTERVAL }=
if (!state.sessions) throw new Error('redux-sessions: error when attempting to save state. Did you remember to attach the reducer at key `sessions`?')
return saveSessionState(state.sessions)
}
store.subscribe(debounce(persistState, debounceInterval))
store.subscribe(throttle(persistState, debounceInterval))
return store
}
}
Expand Down

0 comments on commit 210009f

Please sign in to comment.