Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import { combineReducers } from "redux";
  2. import types from "./types";
  3.  
  4. /* State Shape
  5. {
  6. quacking: bool,
  7. distance: number
  8. }
  9. */
  10.  
  11. const quackReducer = ( state = false, action ) => {
  12. switch( action.type ) {
  13. case types.QUACK: return true;
  14. /* ... */
  15. default: return state;
  16. }
  17. }
  18.  
  19. const distanceReducer = ( state = 0, action ) => {
  20. switch( action.type ) {
  21. case types.SWIM: return state + action.payload.distance;
  22. /* ... */
  23. default: return state;
  24. }
  25. }
  26.  
  27. const reducer = combineReducers( {
  28. quacking: quackReducer,
  29. distance: distanceReducer
  30. } );
  31.  
  32. export default reducer;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement