Skip to content

Instantly share code, notes, and snippets.

@tonkec
Created March 6, 2019 11:38
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 tonkec/85fcfb711970fcbb83793c3db1fe8247 to your computer and use it in GitHub Desktop.
Save tonkec/85fcfb711970fcbb83793c3db1fe8247 to your computer and use it in GitHub Desktop.
// action generator returns action object!!
const incrementCount = ( payload = {} ) => {
// if payload doesn't exist it defaults to {}
// calling property on undefined object will throw an error
// payload is an object passed to incrementCount
return {
// returns new action object!
type: 'INCREMENT',
incrementBy: typeof payload.incrementBy === "number" ? payload.incrementBy : 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment