Created
October 2, 2019 12:29
-
-
Save alonbardavid/e00cfaa006a0d7f2b8d3e2df367ed4da to your computer and use it in GitHub Desktop.
Patterns for deriving state gist9
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
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