Skip to content

Latest commit

 

History

History

docs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
id title hide_title sidebar_label
redux-leaves
reduxLeaves
true
reduxLeaves

reduxLeaves(initialState, [reducersDict = {}])

Returns a reducer function and an actions object.

See the 30 second demo for usage.

Parameters

initialState

(object)

This is the state shape and initial values for your Redux store.

It is described as having state 'branches' and 'leaves'.

Example

const initialState = {
  todos: {
    byId: {},
    allIds: []
  },
  visibilityFilter: "SHOW_ALL"
}

reducersDict

(object)

This is an object where every key-value pair is such that:

Example

const reducersDict = {
  increment: (state, { payload }) => state + payload,
  slice: {
    argsToPayload: (begin, end) => [begin, end]
    reducer: (state, { payload }) => state.slice(payload[0], payload[1])
  }
}

Returns

array, with two elements:

  • 0th: reducer (function): a reducer function to pass to redux's createStore
  • 1st: actions (object): an object with same shape as initialState

reducer

The root reducer for your Redux store.

It listens to actions created through actions at a given leaf for a given creator key, and updates that leaf's state using the leaf reducer keyed by the creator key.

actions

See documentation on the actions object.