reset()
create.reset
create(actionType).reset
Appropriate leaf state: any
Returns an (action) object that the reduxLeaves reducer uses to non-mutatively reset the leaf's state to its initial state as passed into reduxLeaves
.
Returns
action
(object): an object to dispatch to the store
Example
import { createStore } from 'redux'
import reduxLeaves from 'reduxLeaves'
const initialState = {
num: 2,
arr: [1, 2, 3],
bool: true
}
const otherState = {
num: 11,
arr: [4, 5, 6],
bool: false
}
const [reducer, actions] = reduxLeaves(initialState)
const store = createStore(reducer, otherState) // preloads otherState
/* store.getState()
* {
* num: 11,
* arr: [4, 5, 6]
* }
*/
create.reset
on a leaf:
Calling const resetNum = actions.num.create.reset
store.dispatch(resetNum())
console.log(store.getState().num) // 2
create(actionType).reset
on a leaf:
Calling const resetBool = actions.bool.create.reset
store.dispatch(resetBool())
console.log(store.getState().bool) // true
create.reset
on a branch:
Calling const resetState = actions.create.reset
store.dispatch(resetState())
console.log(store.getState()) // { num: 2, arr: [1, 2, 3], bool: true }