GitHub package.json versionTypeScriptNPM
GitHub package.json versionTypeScriptNPM

store.setState @@PUSH Tag Usage

Sample:
store.setState({
    stateKey0: { // where `state.stateKey0` is an array
        '@@PUSH': [ // performs array push on `state.stateKey0`.
            1,
            2,
            3,
        ]
    }
});

Example:

1 2 3 4 5 6 7 8 9 10 11 import { PUSH_TAG } from '@webkrafters/react-observable-context'; // PUSH_TAG = "@@PUSH" const state = { a: { b: [{ x: 7, y: 8, z: 9 }, { x: 17, y: 18, z: 19 }] }, j: 10 }; store.setState({ a: { [ PUSH_TAG ]: [{ n: 5 }] } }); // assigning a '@@PUSH' command to a non-array property has no effect. /* appends 2 new items into state.a.b; leaving state.a.b = [...state.a.b, { x: 27, y: 28, z: 29 }, { x: 37, y: 38, z: 39 }] */ store.setState({ a: { b: { [ PUSH_TAG ]: [{ x: 27, y: 28, z: 29 }, { x: 37, y: 38, z: 39 }] } } });