GitHub package.json versionTypeScriptNPM
GitHub package.json versionTypeScriptNPM

@@CLEAR Tag Usage

Signature 1: '@@CLEAR'

Signature 2:
{ '@@CLEAR': <any> }; // the value has no effect.

Example:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 import AutoImmutable, { Tag } from 'auto-immutable'; const protectedData = { a: { b: [ { x: 7, y: 8, z: 9 }, { x: 17, y: 18, z: 19 } ] }, j: 10 }; const aImmutable = new AutoImmutable( protectedData ); const consumer = aImmutable.connect(); /* empties aImmutable data; sets aImmutable data = {} */ consumer.set( Tag.CLEAR ) // or consumer.set({ [ Tag.CLEAR ]: <anything> }) // empties the value at aImmutable data.a.b; // sets aImmutable data.a.b = [] consumer.set({ a: { b: Tag.CLEAR // or { [ Tag.CLEAR ]: <anything> } } }); // empties the value at aImmutable data.a.j; // sets aImmutable data.a.j = null consumer.set({ a: { j: Tag.CLEAR // or { [ Tag.CLEAR ]: <anything> } } }); // empties the value at aImmutable data.a.b[ 0 ]; // sets aImmutable data.a.b = [{}] consumer.set({ a: { b: [ Tag.CLEAR ] // or { [ Tag.CLEAR ]: <anything> } } }); // empties the value at aImmutable data.a.b[0]; // sets aImmutable data.a.b = [{}, aImmutable data.a.b[1]] consumer.set({ a: { b: [ Tag.CLEAR, // or { [ Tag.CLEAR ]: <anything> } aImmutable data.a.b[1] ] } }); // empties the value at aImmutable data.a.b[0]; // sets aImmutable data.a.b = [{}, a.b[1]] // uses indexing (RECOMMENDED) consumer.set({ a: { b: { 0: Tag.CLEAR // or { [ Tag.CLEAR ]: <anything> } } } });