id | title | hide_title | sidebar_label |
---|---|---|---|
redux-leaves |
reduxLeaves |
true |
reduxLeaves |
Returns a reducer function and an actions object.
See the 30 second demo for usage.
initialState
(object): the state shape and initial values for your Redux storereducersDict
(object, optional): a collection of leaf reducers keyed by their creator keys
(object)
This is the state shape and initial values for your Redux store.
It is described as having state 'branches' and 'leaves'.
const initialState = {
todos: {
byId: {},
allIds: []
},
visibilityFilter: "SHOW_ALL"
}
(object)
This is an object where every key
-value
pair is such that:
value
(function | object) is a leaf reducer;key
is a creator key for that leaf reducer.
const reducersDict = {
increment: (state, { payload }) => state + payload,
slice: {
argsToPayload: (begin, end) => [begin, end]
reducer: (state, { payload }) => state.slice(payload[0], payload[1])
}
}
array
, with two elements:
- 0th:
reducer
(function): a reducer function to pass to redux'screateStore
- 1st:
actions
(object): an object with same shape asinitialState
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.
See documentation on the actions
object.