set(key, value)
create.set
create(actionType).set
Appropriate leaf type: object
Returns a Riduce-standard action to non-mutatively update the leaf's state at the property key
with value
.
key
(string): the path of the property to setvalue
(any): the value to setaction
(object): a Riduce-standard action
import { createStore } from 'redux'
import riduce from 'riduce'
const initialState = {
foo: {},
bar: { props: true }
}
const [reducer, actions] = riduce(initialState)
const store = createStore(reducer)
const setInFoo = actions.foo.create.set
store.dispatch(setInFoo('accessed', true))
console.log(store.getState().foo) // { accessed: true }
const setInBar = actions.bar.create.set
store.dispatch(setInBar('props', false))
console.log(store.getState().bar) // { props: false }