toggle()
create.toggle
create(actionType).toggle
Appropriate leaf state: boolean
Returns an (action) object that the reduxLeaves reducer uses to update the leaf's state to !leafState
.
Returns
action
(object): an object to dispatch to the store
Example
import { createStore } from 'redux'
import reduxLeaves from 'reduxLeaves'
const initialState = {
foo: true,
bar: false
}
const [reducer, actions] = reduxLeaves(initialState)
const store = createStore(reducer)
create.toggle
Calling const toggleFoo = actions.foo.create.toggle
store.dispatch(toggleFoo())
console.log(store.getState().foo) // false
create(actionType).toggle
Calling const toggleBar = actions.bar.create('TOGGLE_BAR').toggle
store.dispatch(toggleBar())
console.log(store.getState().bar) // true