Skip to content

Instantly share code, notes, and snippets.

@alonbardavid
Created October 2, 2019 12:29
Show Gist options
  • Save alonbardavid/e00cfaa006a0d7f2b8d3e2df367ed4da to your computer and use it in GitHub Desktop.
Save alonbardavid/e00cfaa006a0d7f2b8d3e2df367ed4da to your computer and use it in GitHub Desktop.
Patterns for deriving state gist9
function setSetDays(days){
return (dispatch,getState)=>{
dispatch({
type:actionTypes.SET_DAYS,
payload:days
})
}
}
function setFormatted(formatted){
return (dispatch,getState)=>{
const [count,unit] = formatted.split(" ");
const days = unit === "weeks"? count * 7: count;
dispatch({
type:actionTypes.SET_DAYS,
payload:days
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment