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.

Parameters

Returns

action (object): a Riduce-standard action

Example

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)

Assigning new properties

const assignToFoo = actions.foo.create.assign
store.dispatch(assignToFoo({ count: 2 }))
console.log(store.getState().foo) // { props: true, count: 2 }

Overwriting properties

const assignToBar = actions.bar.create.assign
store.dispatch(assignToBar({ props: true }))
console.log(store.getState().bar) // { props: true }