concat(arrayOrString)
create.concat
create(actionType).concat
Appropriate leaf state: array | string
Returns an (action) object that the reduxLeaves reducer uses to update the leaf's state by concatening it with arrayOrString
.
Parameters
arrayOrString
(array | string): the array to concatenate
Returns
action
(object): an object to dispatch to the store
Example
import { createStore } from 'redux'
import reduxLeaves from 'reduxLeaves'
const initialState = {
arr: [1, 2, 3],
str: 'foo'
}
const [reducer, actions] = reduxLeaves(initialState)
const store = createStore(reducer)
Concatenating an array
const concatToArr = actions.arr.create.concat
store.dispatch(concatToArr(['a', 'b', 'c']))
console.log(store.getState().arr) // [1, 2, 3, 'a', 'b', 'c']
Concatenating a string
const concatToStr = actions.str.create.concat
store.dispatch(concatToStr('bar'))
console.log(store.getState().str) // 'foobar'