Skip to content

Instantly share code, notes, and snippets.

@asfktz
Last active June 8, 2017 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asfktz/214e06a746e0df859ec8efec9038d716 to your computer and use it in GitHub Desktop.
Save asfktz/214e06a746e0df859ec8efec9038d716 to your computer and use it in GitHub Desktop.
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