Accessing Auto Immutable Data
Any Auto Immutable instance communicates with its environment through its own
Connection class (the consumer) instances.The
get(...) method of the Connection instance provides the means of accessing and obtaining Immutable data.This method is variadic accepting only property path argument(s).
The data returned from this method is a snapshot of the Auto Immutable instance data at the time of access.
This snapshot data is not affected by further updates to the Auto Immutable instance data.
Any further alterations to the snapshot data do not reach the Auto Immutable instance.
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
import AutoImmutable from 'auto-immutable';
const aImmutable = new AutoImmutable({
a: {
b: 5,
c: [ 6, {
d: 7,
e: 8,
f: 9
} ]
}
});
const consumer = aImmutable.connect();
consumer.get( 'a.c[1]', 'b' );
// returns:
// {
// 'a.c[1]': {
// d: 7,
// e: 8,
// f: 9
// },
// b: 5
// }