Action creator creator for flux standard actions. Very similar to the function of the same name found in redux-actions, but implemented as a micro-module and without the special error handling stuff.
$ npm install @f/create-action
var createAction =var incrementBy =// ...
createAction(type, payloadCreator, metaCreator)
type- String or other identifier that represents the type of the action to create
payloadCreator- Function that produces
payloadfrom the arguments to the action creator (optional - defaults to https://github.com/micro-js/identity)
metaCreator- Function that produces
metafrom the arguments to the action creator (optional)
Returns: An action creator that creates an action according to the arguments specified.
Action creators returned by
Function.prototype.toString, and instead return the type string. This allows the function to double as the action type, for useThis means that instead of writing this:
const SET_TEXT = 'SET_TEXT'const setText =
You can just write this:
And then use it in a reducer map, like this:
toString as above makes you squeamish, then the type is also set on the
type property of the action creator, so that you can access it that way as well, if you prefer.