Skip to content

Commit

Permalink
Add support for enhancers in persistState
Browse files Browse the repository at this point in the history
Fix error when using enhancer like applyMiddleware as parameter in createPersistentStore
  • Loading branch information
Eysenck Gómez committed Apr 14, 2016
1 parent d0cb14c commit c4a8bf3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/persistState.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export default function persistState(paths, config) {
deserialize
} = cfg

return next => (reducer, initialState) => {
return next => (reducer, initialState, enhancer) => {
if (typeof initialState === 'function' && typeof enhancer === 'undefined') {
enhancer = initialState
initialState = undefined
}

let persistedState
let finalInitialState

Expand All @@ -46,7 +51,7 @@ export default function persistState(paths, config) {
console.warn('Failed to retrieve initialize state from localStorage:', e)
}

const store = next(reducer, finalInitialState)
const store = next(reducer, finalInitialState, enhancer)
const slicerFn = slicer(paths)

store.subscribe(function () {
Expand Down

0 comments on commit c4a8bf3

Please sign in to comment.