Last active
June 8, 2017 16:23
-
-
Save asfktz/214e06a746e0df859ec8efec9038d716 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MyWrapperMiddleware = store => next => action => { | |
const state = store.getState() | |
if (!state.isLoggedIn) | |
return next(action) | |
const pouchMiddleware = PouchMiddleware({ | |
path: state.currentPath, | |
db, | |
actions: { | |
remove: doc => { return { type: types.DELETE_TODO, id: doc._id } }, | |
insert: doc => { return { type: types.INSERT_TODO, todo: doc } }, | |
batchInsert: docs => { return { type: types.BATCH_INSERT_TODOS, todos: docs } } | |
update: doc => { return { type: types.UPDATE_TODO, todo: doc } }, | |
} | |
}) | |
return pouchMiddleware(store)(next)(action) | |
} | |
export default MyWrapperMiddleware |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment