redux-structure-factory
v0.2.0-beta
Published
Factory module to create a redux structure
Downloads
2
Maintainers
Readme
Status
redux-structure-factory
Factory module to create a redux structure
Installation
TBD
Usage
Container configuration
Configuration object
{
'label': 'Some Name',
'defaultState': {},
'actions': {
'ACTION_KEY': {
'actionName': 'An action',
'actionCreator': function(...payload){ ... },
'reducerAction': function(state, action) { ... }
}
},
'filter': {
'filterName': function(...filterArgs){ ... }
}
}
Description
| Field Name | Type | Description |
| - | - | - |
| label | string | Redux container label. If not existing, registered name will be used.Mandatory: false|
| defaultState | object | Default state. If no default state is defined an empty object will be used.Mandatory: false|
| actions | object | Holds all actions with it's respective action creator function and reducer functionMandatory: true |
| ACTION_KEY | object | Name of the action. It will be automatically converted to camelCase
and used as the function name.Must be UPPER_CASE [A_Z_]
. Otherwise it will be ignored!Mandatory: true |
| actionName | string | Descriptive text of the action.Mandatory: true |
| actionCreator | function | Creates a valid action for processing the calculation of the new state. Only pure JSON (see also http://json.org/) values are allowed. Other value types will be stringified with JSON.stringify()
and if that returns undefined
the function toString()
is tried to be called. If this also returns undefined
the payload parameter will be ignored. Also parameter with value undefined
are ignored.If the field is missing an simple object with just the type
and an empty payload
object will be created.Mandatory: false@param
...payload (optional) One ore more arguments to store inside the payload for calculating the new state.@return
Object with fields type
which is the same as ACTION_NAME
and payload
where the calculated payload is stored into.|
| reducerAction | function | Calculates the new partial state the container is responsible for. If no return value is present for the reducer, the factory takes care of returning the original state. Mandatory: true@param
state A copy of the old state. The factory takes care of passing a copy of the old state. So the second Redux principle isn't violated. The state can safely be altered. @param
action Object with fields type
which is the same as ACTION_NAME
and payload
where the payload is stored into.@return
The new state |
| filter | object | Contains functions to filter the state.Mandatory: false|
| filterName | function | Filters the state and returns only the information wanted.Mandatory: false@param
...filterArgs (optional) One or more arguments to narrow the filter result@return
Filtered value or null if no matching value can be found |
API
TBD
License
This module is licensed under the GNU GENERAL PUBLIC LICENSE Version 3. For more details have a look inside the LICENSE file or visit the official page.