Guest User

Untitled

a guest
Oct 23rd, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. const createStore = require('redux').createStore
  2.  
  3. function counter(
  4. state = { location: 'shanghai', driveTime: 36000, driveDistance: '10000' },
  5. action
  6. ) {
  7. switch (action.type) {
  8. case 'pushLocation':
  9. return state.location
  10. case 'pushDriveTime':
  11. return state.driveTime
  12. case 'pushDriveDistance':
  13. return state.driveDistance
  14. default:
  15. return state
  16. }
  17. }
  18.  
  19. let store = createStore(counter)
  20.  
  21. store.subscribe(() => console.log(store.getState()))
  22. store.dispatch({ type: 'pushDriveDistance' })
Add Comment
Please, Sign In to add comment