Created
February 21, 2016 05:52
-
-
Save chapel/426478c5b2db15d9a2d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const simpleAction = () => { | |
return { | |
type: 'SIMPLE_ACTION' | |
}; | |
}; | |
export const complexAction = (arg) => { | |
return { | |
type: 'COMPLEX_ACTION', | |
arg | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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