generateActions(actionGenesis) ⇒ ActionStruct
A higher-order function that mirrors the supplied
actionGenesis
structure, returning an
ActionStruct
, injecting generated action creators that
are decorated with their coresponding action types.
A Closer Look
diagrams this process. Examples can be
found throughout the Dev Guide, starting with
Basics
.
Param | Type | Description |
---|---|---|
actionGenesis | ActionGenesis |
an "organizational" JSON structure that defines one or more action creators, with implicitly defined action types (gleaned from the structure itself). |
Returns: ActionStruct
- an action structure (a mirror of
actionGenesis
), with generated action creators that
are decorated with their cooresponding action types.
generateActions.root(actionGenesis) ⇒ ActionStruct
The generateActions.root()
function is identical to
generateActions()
, except it returns the single root
node of the ActionStruct
, rather than the entire
structure. This is useful for projects that organize their
actions in seperate JavaScript modules (see
Action Promotion
).
Param | Type | Description |
---|---|---|
actionGenesis | ActionGenesis |
an "organizational" JSON structure that defines one or more action creators, with implicitly defined action types (gleaned from the structure itself). For generateActions.root() , this is expected to contain a single root node (which will be returned). |
Returns: ActionStruct
- the root action structure (a mirror of
actionGenesis
), with generated action creators that
are decorated with their cooresponding action types.
ratifyFn(...args) ⇒ args
An optional hook ofActionMeta
to validate and/or default
action creator parameters.
validation is accomplished by app-specific means (typically thrown exceptions)
default parameters are accomplished by applying default semantics and returning the arguments
Please refer to Parameter Validation
and
Defaulting Parameters
for complete examples.
Param | Type | Description |
---|---|---|
...args | * | the parameters to this function should match that of the action creator it is defining |
Returns: args - an array of the arguments passed in (potentially
defaulted). NOTE: You should never attempt to return the
built-in arguments
array-like object for two reasons: 1.
applied defaults are NOT reflected in arguments
, and 2.
arguments
are not bound to arrow functions.
ActionNode(...args) ⇒ Action
ActionNode is a generated action creator function that lives as a
JSON node in the ActionStruct
.
The ActionNode promotes it's action type through a string coercion of the action creator function itself (i.e. the function's toString() has been overloaded).
A Closer Look
diagrams the action-u formal types.
Param | Type | Description |
---|---|---|
...args | * | the parameters are app-specific to this action type. |
Returns: Action
- a standard redux Action, specific to this action
type.
ActionGenesis : JSON
ActionGenesis is a JSON meta structure (used bygenerateActions()
) that provides the master definition
for the generated ActionStruct
, promoting one or more
action creators and types.
A Closer Look
diagrams the action-u formal types.
The structure is app-specific and can employ depth to highlight inner-relationships between various action creators.
Ultimately the structure defines one or more action creator function nodes. Each of these nodes promote:
the action creator function itself, and
the action type, which is implicitly gleaned from the containing JSON structure node accumulation (ex:
'widget.fetch'
)
Nodes containing an
actionMeta
property define anActionNode
(i.e. an action creator).The resultant corresponding node will be an action creator function. The characteristics of this function is further defined by
actionMeta
sub-properties (seeActionMeta
).The action type is implied from the containing JSON structure node accumulation (ex:
'widget.fetch.complete'
) and is promoted through a string coercion of the action creator function itself (i.e. the function's toString() has been overloaded).
All other nodes are merely intermediate nodes that organize (i.e. add meaning) to the overall shape of the promoted actions. In the example below,
widget
is an intermediate node (i.e. it is not an action creator).Note that even
ActionNodes
may in turn contain sub-structure (i.e. subordinate actions). In the example below,widget.fetch(selCrit)
is an action creator, an yet contains subordinate actions:widget.fetch.complete(widget)
.
Example (showing a standard set of fetch/complete/fail actions)
{
widget: {
fetch: {
actionMeta: {
traits: ['selCrit']
},
complete: {
actionMeta: {
traits: ['widget']
}
},
fail: {
actionMeta: {
traits: ['err']
}
}
}
}
}
ActionMeta : JSON
An ActionMeta is a sub-node (namedactionMeta
) in the
ActionGenesis
that identifies it's parent as being an
ActionNode
(i.e. an action creator).
A Closer Look
diagrams the action-u formal types.
Supported properties of ActionMeta are:
Properties
Name | Type | Description |
---|---|---|
traits | Array.<string> | An array of names that serve BOTH as the:
Basics discussion for complete examples. |
ratify | ratifyFn |
An optional hook to validate and/or default action creator parameters. When NO ratify function is supplied, only simple validation is performed (ex: the number of arguments supplied). Please refer to Parameter Validation and Defaulting Parameters for complete examples. |
thunk | function | An action creator function that promotes a thunk. When thunk is used, no other ActionMeta properties are allowed. Please refer to Thunk Action Creators for a complete description. |
ActionStruct : JSON
ActionStruct is a JSON stucture which is a key aspect of action-u. It:- implicitly defines your action types,
- instinctively groups related actions,
- and seamlessly promotes both action creators and types throughout your application.
ActionStruct is a generated JSON run-time structure (output from
generateActions()
) that promotes a series of action
creators and types in an app-specific structure (mirroring the
shape of the ActionGenesis
).
A Closer Look
diagrams the action-u formal types.
The structure is app-specific and can employ depth to highlight inner-relationships between various action creators.
The structure defines one or more
ActionNodes
(i.e. action creator functions). EachActionNode
encapsolates BOTH the action creator and it's type.The action creator function (the node itself) accepts the desired parameters and returns a newly created action.
The action type is implied from the containing JSON structure node accumulation (ex:
'widget.fetch.complete'
) and is promoted through a string coercion of the action creator function itself (i.e. the function's toString() has been overloaded).
All other nodes are merely intermediate nodes that organize (i.e. add meaning) to the overall shape of the promoted actions. In the example below,
widget
is an intermediate node (i.e. it is not an action creator).Note that even
ActionNodes
may in turn contain sub-structure (i.e. subordinate actions). In the example below,widget.fetch(selCrit)
is an action creator, an yet contains subordinate actions:widget.fetch.complete(widget)
.
Example (showing a standard set of fetch/complete/fail actions)
{
widget: {
fetch(selCrit): { // action creator (impl omitted) - type promoted via string coercion of funct
complete(widget): {} // action creator (impl omitted) - type promoted via string coercion of funct
fail(err): {} // action creator (impl omitted) - type promoted via string coercion of funct
}
}
}
Action : Object
A standard redux Action object that drives the reduction process.Properties
Name | Type | Description |
---|---|---|
type | string | The action type. |
whatever | * | Additional app-specific payload (as needed). |