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.
path (string[]): an array of strings which represent the property path to set atvalue (any): the value to setaction (object): a Riduce-standard action
import { createStore } from 'redux'
import riduce from 'riduce'
const initialState = {
foo: {}
bar: { arbitrary: { keys: 3 } }
}
const [reducer, actions] = riduce(initialState)
const store = createStore(reducer)
const setAtPathInFoo = actions.foo.create.path
store.dispatch(setAtPathInFoo(['nested', 'deep'], true))
console.log(store.getState().foo) // { nested: { deep: true } }
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 } }