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.

Parameters

Returns

action (object): a Riduce-standard action

Example

import { createStore } from 'redux'
import riduce from 'riduce'

const initialState = {
  foo: {},
  bar: { props: true }
}

const [reducer, actions] = riduce(initialState)
const store = createStore(reducer)

Setting a new property

const setInFoo = actions.foo.create.set
store.dispatch(setInFoo('accessed', true))
console.log(store.getState().foo) // { accessed: true }

Overwriting a property

const setInBar = actions.bar.create.set
store.dispatch(setInBar('props', false))
console.log(store.getState().bar) // { props: false }