clear()
create.clear
create(actionType).clear
Appropriate leaf state: any
Returns a Riduce-standard action used to clears the leaf's state.
It follows the type of the leaf's state:
0
''
false
[]
{}
action
(object): a Riduce-standard action
import { createStore } from 'redux'
import riduce from 'riduce'
const initialState = {
bool: true,
num: 2,
str: 'foo',
arr: [1, 2, 3]
}
const [reducer, actions] = riduce(initialState)
const store = createStore(reducer)
const clearBool = actions.bool.create.clear
store.dispatch(clearBool())
console.log(store.getState().bool) // false
const clearNum = actions.num.create.clear
store.dispatch(clearNum())
console.log(store.getState().num) // 0
const clearStr = actions.str.create.clear
store.dispatch(clearStr())
console.log(store.getState().str) // ''