Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 770 Bytes

README.md

File metadata and controls

41 lines (28 loc) · 770 Bytes

push(path, ...value) ⇒ object

Adds elements to the end of array

Returns: object - action object
Params

  • path number | string | Array.<(string|number)> - path to be updated (array of items or dot-separated string can be provided)
  • ...value any - value to be added

Description

import { ACTIONS, reducer } from 'general-reducer';

const state = {
    a: {
        b: [ 1 ]
    }
};

const updated = reducer(state, ACTIONS.push('a.b', 2, 3));

// or

const updated = reducer(state, ACTIONS.push([ 'a', 'b' ], 2, 3));

As a result we will receive new object with structure below:

{
    a: {
        b: [ 1, 2, 3 ]
    }
}