0.2.0-beta • Published 7 years ago

redux-structure-factory v0.2.0-beta

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

Status

Build 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 NameTypeDescription
labelstringRedux container label. If not existing, registered name will be used.Mandatory: false
defaultStateobjectDefault state. If no default state is defined an empty object will be used.Mandatory: false
actionsobjectHolds all actions with it's respective action creator function and reducer functionMandatory: true
ACTION_KEYobjectName 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
actionNamestringDescriptive text of the action.Mandatory: true
actionCreatorfunctionCreates 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.
reducerActionfunctionCalculates 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
filterobjectContains functions to filter the state.Mandatory: false
filterNamefunctionFilters 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.