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