Skip to content

Commit

Permalink
feat(redux): add logger middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
kiki-le-singe committed Jan 8, 2017
1 parent a7141c8 commit 580446e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/common/redux/middleware/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Logs all actions and states after they are dispatched.
*/
const logger = store => next => (action) => {
// Notes:
// next = store.dispatch;
// next(action) = dispatch(action);

if (__CLIENT__) {
/* eslint-disable */
console.group(action.type)
console.info('dispatching', action)
const result = next(action)
console.log('next state', store.getState())
console.groupEnd(action.type)
return result
}

return
}

export default logger

0 comments on commit 580446e

Please sign in to comment.