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