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:

Returns

action (object): a Riduce-standard action

Example

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)

Boolean state

const clearBool = actions.bool.create.clear

store.dispatch(clearBool())
console.log(store.getState().bool) // false

Number state

const clearNum = actions.num.create.clear

store.dispatch(clearNum())
console.log(store.getState().num) // 0

String state

const clearStr = actions.str.create.clear

store.dispatch(clearStr())
console.log(store.getState().str) // ''

Array state