createAction(s)
Methods
createAction
createAction(
type,
payloadCreator = Identity,
?metaCreator
)Wraps an action creator so that its return value is the payload of a Flux Standard Action.
NOTE: The more correct name for this function is probably createActionCreator(), but that seems a bit redundant.
createAction(type)
createAction(type)Calling createAction with a type will return an action creator for dispatching actions. type must implement toString and is the only required parameter for createAction.
EXAMPLE
If the payload is an instance of an Error object, redux-actions will automatically set action.error to true.
EXAMPLE
createAction also returns its type when used as type in handleAction or handleActions.
EXAMPLE
Use the identity form to create one-off actions.
EXAMPLE
createAction(type, payloadCreator)
createAction(type, payloadCreator)payloadCreator must be a function, undefined, or null. If payloadCreator is undefined or null, the identity function is used.
NOTE: If payload is an instance of an Error object, payloadCreator will not be called.
EXAMPLE
createAction(type, payloadCreator, metaCreator)
createAction(type, payloadCreator, metaCreator)metaCreator is an optional function that creates metadata for the payload. It receives the same arguments as the payload creator, but its result becomes the meta field of the resulting action. If metaCreator is undefined or not a function, the meta field is omitted.
EXAMPLE
createActions
Returns an object mapping action types to action creators. The keys of this object are camel-cased from the keys in actionMap and the string literals of identityActions; the values are the action creators.
createActions(actionMap[, options])
createActions(actionMap[, options])actionMap is an object which can optionally have a recursive data structure, with action types as keys, and whose values must be either
a function, which is the payload creator for that action
an array with
payloadandmetafunctions in that order, as increateActionmetais required in this case (otherwise use the function form above)
an
actionMap
EXAMPLE
If actionMap has a recursive structure, its leaves are used as payload and meta creators, and the action type for each leaf is the combined path to that leaf:
EXAMPLE
createActions(actionMap, ...identityActions[, options]){#createactionsactionmap-identityactions}
createActions(actionMap, ...identityActions[, options]){#createactionsactionmap-identityactions}identityActions is an optional list of positional string arguments that are action type strings; these action types will use the identity payload creator.
createActions(actionMap[, ...identityActions], options)
createActions(actionMap[, ...identityActions], options)You can prefix each action type by passing a configuration object as the last argument of createActions.
EXAMPLE
'INCREMENT' in this example will be prefixed as counter--INCREMENT.
Last updated