GitHub package.json versionTypeScriptNPM
GitHub package.json versionTypeScriptNPM

store.setState @@REPLACE Tag Usage

Sample:
store.setState({
    stateKey0: {
        '@@REPLACE': <any> // replaces `state.stateKey0` with value 
    }
});

Example:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import { REPLACE_TAG } from '@webkrafters/react-observable-context'; // REPLACE_TAG = "@@REPLACE" const state = { a: { b: [{ x: 7, y: 8, z: 9 }, { x: 17, y: 18, z: 19 }] }, j: 10 }; store.setState({ [ REPLACE_TAG ]: { a: 'Demo', j: 17 } }) // rewrites state to { a: 'Demo', j: 17 }; store.setState({ a: { [ REPLACE_TAG ]: { message: 'Testing...' } } }) // rewrites state.a to { message: 'Testing...' } /* rewrites state.a.b[1] to { x: 97, y: 98, z: 99 }; leaving state.a.b = [{ x: 7, y: 8, z: 9 }, { x: 97, y: 98, z: 99 }] */ store.setState({ a: { b: [ state.a.b[ 0 ], { [ REPLACE_TAG ]: { x: 97, y: 98, z: 99 } } ] } }); /* rewrites state.a.b[1] to { x: 97, y: 98, z: 99 }; leaving state.a.b = [{ x: 7, y: 8, z: 9 }, { x: 97, y: 98, z: 99 }] using indexing (RECOMMENDED) */ store.setState({ a: { b: { 1: { [ REPLACE_TAG ]: { x: 97, y: 98, z: 99 } } } } });