Skip to content

Instantly share code, notes, and snippets.

@DobrinGanev
Created September 1, 2017 04:33
Show Gist options
  • Save DobrinGanev/b7f5a6e12e4b09e7056bb48562130f98 to your computer and use it in GitHub Desktop.
Save DobrinGanev/b7f5a6e12e4b09e7056bb48562130f98 to your computer and use it in GitHub Desktop.
redux last Action
const reducer = ((state = 0, action) => {
switch (action.type) {
case 'INCREMENT': return state + 1
case 'DECREMENT': return state - 1
default: return state
}
})
const initialState = {
count: 0
}
const lastAction = (state = null, action) => {
return action;
}
const rootReducer = combineReducers({
reducer,
lastAction
});
const store = createStore(rootReducer)
store.subscribe(() => {
console.log(store.getState().lastAction)// last action
})
store.dispatch({ type: 'INCREMENT' })
store.dispatch({ type: 'DECREMENT' })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment