Guest User

Untitled

a guest
Jul 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. ```javascript
  2. const addLoggingToDispatch = (store) => {
  3. const rawDispatch = store.dispatch;
  4. return (action) => {
  5. console.group(action.type);
  6. console.log('prev state', store.getState());
  7. console.log('action', action);
  8. const returnValue = rawDispatch(action);
  9. console.log('next state', store.getState());
  10. console.groupEnd(action.type);
  11. return returnValue;
  12. }
  13. }
  14. ```
  15.  
  16. and later in your code
  17.  
  18. ```javascript
  19. store.dispatch = addLoggingToDispatch(store);
  20. ```
Add Comment
Please, Sign In to add comment