import {createStore} from 'redux'
const reducer = (state, action) => {
switch (action.type) {
case 'INCREMENT':
return state = state + action.payload
case 'DECREMENT':
return state = state - action.payload
default:
return state
}
}
const store = createStore(reducer, 0)
store.subscribe(()=>{
console.log('store changed', store.getState())
})
store.dispatch({type: 'INCREMENT', payload: 1})
store.dispatch({type: 'DECREMENT', payload: 6})
Created
October 27, 2016 14:44
-
-
Save joshuajhun/74ae69762b27017e97a67319144a5515 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment