@@PUSH Tag Usage
Signature:{
'@@PUSH': [
...newItemsToAppend
]
}
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
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();
/* assigning a '@@PUSH' command to a non-array property has no effect. */
consumer.set({
a: {
[ Tag.PUSH ]: [
{ n: 5 }
]
}
});
// appends 2 new items into aImmutable data.a.b;
// leaving aImmutable data.a.b = [
// ...aImmutable data.a.b,
// { x: 27, y: 28, z: 29 },
// { x: 37, y: 38, z: 39 }
// ]
consumer.set({
a: {
b: {
[ Tag.PUSH ]: [
{ x: 27, y: 28, z: 29 },
{ x: 37, y: 38, z: 39 }
]
}
}
});