Skip to content

Instantly share code, notes, and snippets.

@narennaik
Last active August 1, 2021 09:08
Show Gist options
  • Save narennaik/52cba102933951b5c24b8ca4c7672842 to your computer and use it in GitHub Desktop.
Save narennaik/52cba102933951b5c24b8ca4c7672842 to your computer and use it in GitHub Desktop.
update the state with the change
const state = {};
const subscribe = (listener) => {
listeners.push(listener);
};
const dispatch = (action/change) => {
const newState = getNewState(state, action);
state = newState;
};
const action = { type: 'ADD_TODO', change: 'Go to the cafe' };
dispatch(action)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment