Skip to content

Instantly share code, notes, and snippets.

@DominicTobias
Last active Jan 29, 2020
Embed
What would you like to do?
appState
const darkTheme = {
name: 'dark',
background: 'black',
text: 'white',
}
const lightTheme = {
name: 'light',
background: 'white',
text: 'black',
}
function reducer(state, actionName, payload) {
switch (actionName) {
case 'toggleTheme':
return {
...state,
theme: state.theme.name === 'light' ? darkTheme : lightTheme,
};
default:
throw new Error(`Action does not exist: ${actionName}`);
}
}
const appState = new GlobalState(reducer, { theme: lightTheme });
export default appState;
@DominicTobias
Copy link
Author

DominicTobias commented Jan 29, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment