Skip to content

Instantly share code, notes, and snippets.

@btg5679
Created July 14, 2017 02:07
Show Gist options
  • Save btg5679/12f13ac0063087951231d593b240fb55 to your computer and use it in GitHub Desktop.
Save btg5679/12f13ac0063087951231d593b240fb55 to your computer and use it in GitHub Desktop.
import { createStore } from 'redux';
const reducer = function(state, action){
if(action.type === 'CMT'){
return state + action.payload;
}
return state;
}
const store = createStore(r, {
user: {
name: 'wacko',
age: 48
},
commentCount: 2,
loginHistory: {
loginDate: '2017-01-01',
result: 'success'
},
...
});
//Action dispatched to your Store
store.dispatch({ type: 'CMT', payload: 1 });
//Called any time an action is dispatched
store.subscribe(());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment