Example:
A basic Flux Standard Action
{
type: ‘ADD_TODO’,
payload: {
text: ‘Do something’,
}
}
`An FSA that represents an error, analogous to a rejected Promise:
`{ type: 'ADD_TODO', payload: new Error(), error: true, }
Notice:
1. An action MUST
- be a plain JavaScript Object
- have a
type
property
- An action MAY:
- have a
error
property - have a
payload
property - have a
meta
property
- An action MUST NOT include properties other than
type
,payload
,error
,meta
Type
The type
of an action identifies to the consumer the nature of the action that has occurred. Two actions with same type
MUST be strictly equivalent (using ===). By convention, type
is usually string constant or a Symbol.
payload
The optional payload
property MAY be any type of value. It represents the payload of the action. Any information about the action that is not the type
or status of the action should be part of the payload
filed.
By convention, if error
is true
, the payload
SHOULD be an error object. This is akin to rejecting a promise with an error object.
error
The optional error
property MAY be set to true
if the action represents an error.
An action whose error
is true is analogous to a rejected Promise. By convention the payload
SHOULD be an error object.
If error
has any other value besides true
, including undefined
and null
, the action MUST NOT be interpreted as an error.
meta
The optional meta
property MAY be any type of value. It is intended for any extra information that is not part of the payload.