toggle()

create.toggle create(actionType).toggle Appropriate leaf state: boolean

Returns a Riduce-standard action to update the leaf's state to !leafState.

Returns

action (object): a Riduce-standard action

Example

import { createStore } from 'redux'
import riduce from 'riduce'

const initialState = {
  foo: true,
  bar: false
}

const [reducer, actions] = riduce(initialState)
const store = createStore(reducer)

Calling create.toggle

const toggleFoo = actions.foo.create.toggle
store.dispatch(toggleFoo())
console.log(store.getState().foo) // false

Calling create(actionType).toggle

const toggleBar = actions.bar.create('TOGGLE_BAR').toggle
store.dispatch(toggleBar())
console.log(store.getState().bar) // true