assign(props)
create.assign
create(actionType).assign
Appropriate leaf type: object
Returns a Riduce-standard action to non-mutatively copy all properties from props
into the leaf's state.
props
(object): the properties to setaction
(object): a Riduce-standard action
import { createStore } from 'redux'
import riduce from 'riduce'
const initialState = {
foo: { props: true },
bar: { props: false }
}
const [reducer, actions] = riduce(initialState)
const store = createStore(reducer)
const assignToFoo = actions.foo.create.assign
store.dispatch(assignToFoo({ count: 2 }))
console.log(store.getState().foo) // { props: true, count: 2 }
const assignToBar = actions.bar.create.assign
store.dispatch(assignToBar({ props: true }))
console.log(store.getState().bar) // { props: true }