Skip to content

Instantly share code, notes, and snippets.

@chapel
Created February 21, 2016 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chapel/426478c5b2db15d9a2d3 to your computer and use it in GitHub Desktop.
Save chapel/426478c5b2db15d9a2d3 to your computer and use it in GitHub Desktop.
export const simpleAction = () => {
return {
type: 'SIMPLE_ACTION'
};
};
export const complexAction = (arg) => {
return {
type: 'COMPLEX_ACTION',
arg
};
};
export const reducer = (state, action) => {
switch(action.type) {
case SIMPLE_ACTION:
return {
...state,
simple: true
};
case COMPLEX_ACTION:
let arg = action.arg;
if (arg > 100) {
return {
...state,
argOver100: true
};
}
if (arg > 1000) {
return {
..state,
argOver1000: true
};
}
if (arg === 599) {
return {
..state,
price: arg
};
}
return state;
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment