drop([n = 1])
create.drop
create(actionType).drop
Appropriate leaf state: array
Returns an (action) object that the reduxLeaves reducer uses to non-mutatively drop the first n
elements from the leaf's state.
Parameters
n
(number, optional): the number of elements to drop
Returns
action
(object): an object to dispatch to the store
Example
import { createStore } from 'redux'
import reduxLeaves from 'reduxLeaves'
const initialState = {
foo: ['a', 'b', 'c'],
bar: ['a', 'b', 'c']
}
const [reducer, actions] = reduxLeaves(initialState)
const store = createStore(reducer)
No argument provided
const dropFromFoo = actions.foo.create.drop
store.dispatch(dropFromFoo())
console.log(store.getState().foo) // ['b', 'c']
Providing an argument
const dropFromBar = actions.bar.create.drop
store.dispatch(dropFromBar(2))
console.log(store.getState().bar) // ['c']