path(path, value)

create.path create(actionType).path Appropriate leaf type: object

Returns a Riduce-standard action to non-mutatively set a property at path from the leaf as value.

Parameters

Returns

action (object): a Riduce-standard action

Example

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

const initialState = {
  foo: {}
  bar: { arbitrary: { keys: 3 } }
}

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

Setting a new property

const setAtPathInFoo = actions.foo.create.path
store.dispatch(setAtPathInFoo(['nested', 'deep'], true))
console.log(store.getState().foo) // { nested: { deep: true } }

Overwriting a property

const setAtPathInBar = actions.bar.create("SET_AT_PATH_IN_BAR").path
store.dispatch(setAtPathInBar(['arbitrary', 'keys'], 5))
console.log(store.getState().bar) // { arbitrary: { keys: 5 } }