Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const createStore = require('redux').createStore
- function counter(
- state = { location: 'shanghai', driveTime: 36000, driveDistance: '10000' },
- action
- ) {
- switch (action.type) {
- case 'pushLocation':
- return state.location
- case 'pushDriveTime':
- return state.driveTime
- case 'pushDriveDistance':
- return state.driveDistance
- default:
- return state
- }
- }
- let store = createStore(counter)
- store.subscribe(() => console.log(store.getState()))
- store.dispatch({ type: 'pushDriveDistance' })
Add Comment
Please, Sign In to add comment