@@ -5,8 +5,113 @@ sidebar_label: Properties
55slug : /core/collection/properties
66---
77
8- ::: warning
8+ ::: info
99
10- WIP docs!
10+ Here useful properties of the ` State ` are listed.
11+
12+ :::
13+
14+ ## ` agileInstance `
15+ Returns the Agile Instance to which the Collection belongs.
16+ Be aware that it gets in function shape returned.
17+ ``` ts
18+ MY_STATE .agileInstance (); // Returns a Agile Instance
19+ ```
20+ The reason for that is to avoid endless deep classes.
21+
22+ ## ` key `
23+ Returns the current Key/Name of the Collection.
24+ A Key is used to uniquely identify the Collection.
25+ Besides getting the key, we can also assign a new Key with this property.
26+ ``` ts
27+ MY_COLLECTION .key = " myCoolCollection" ;
28+ MY_COLLECTION .key ; // Returns 'myCoolCollection'
29+ ```
30+
31+ ## ` size `
32+ Returns the current size of the Collection,
33+ so how many Items are stored in the Collection
34+ to this point in time.
35+ ``` ts {3}
36+ MY_COLLECTION .collect ({id: 1 , name: " jeff" });
37+ MY_COLLECTION .collect ({id: 5 , name: " frank" });
38+ MY_COLLECTION .size ; // Returns 2
39+ ```
40+
41+ ## ` data `
42+ Here all Items of the Collection are stored.
43+ ``` ts {3}
44+ MY_COLLECTION .collect ({id: 1 , name: " jeff" });
45+ MY_COLLECTION .collect ({id: 5 , name: " frank" });
46+ MY_COLLECTION .data ; // Returns (see below)
47+ // {
48+ // 1: Item({id: 1, name: "jeff"}),
49+ // 5: Item({id: 5, name: "frank"})
50+ // }
51+ ```
52+ We recommend using the ` getAllItems ` function to get assess to all Items,
53+ ``` ts {1}
54+ MY_COLLECTION .getAllItems (); // Returns (see below)
55+ // [
56+ // Item({id: 1, name: "jeff"}),
57+ // Item({id: 5, name: "frank"})
58+ // ]
59+ ```
60+ or the ` default Group ` ,
61+ ``` ts {1}
62+ MY_COLLECTION .getGroup (MY_COLLECTION .config .defaultGroupKey ).items ; // Returns (see below)
63+ // [
64+ // Item({id: 1, name: "jeff"}),
65+ // Item({id: 5, name: "frank"})
66+ // ]
67+ ```
68+ because the ` data ` property should only be used internal!
69+
70+ ## ` isPersisted `
71+ If the Collection Value got persisted into a Storage like the Local Storage.
72+ ``` ts {1,3}
73+ MY_COLLECTION .isPersisted ; // Returns false
74+ MY_COLLECTION .persist ();
75+ MY_COLLECTION .isPersisted ; // Returns true (if the persisting was successfull)
76+ ```
77+
78+ ## ` groups `
79+ Here all [ Groups] ( ./group/Introduction.md ) of the Collection are stored.
80+ ``` ts {3}
81+ MY_COLLECTION .createGroup (" group1" , [1 , 2 , 3 ]);
82+ MY_COLLECTION .createGroup (" group2" , [1 , 7 , 4 ]);
83+ MY_COLLECTION .groups ; // Returns (see below)
84+ // {
85+ // group1: Group([1, 2, 3]),
86+ // group2: Group([1, 7, 4])
87+ // }
88+ ```
89+ If you want to get a specific Group, please use
90+ ``` ts
91+ MY_COLLECTION .getGroup (" group1" );
92+ ```
93+ instead of
94+ ``` ts
95+ MY_COLLECTION .groups [" group1" ]
96+ ```
97+
98+ ## ` selectors `
99+ Here all [ Selectors] ( ./selector/Introduction.md ) of the Collection are stored.
100+ ``` ts {3}
101+ MY_COLLECTION .createGroup (" selector1" , 1 );
102+ MY_COLLECTION .createGroup (" selector2" , 7 );
103+ MY_COLLECTION .groups ; // Returns (see below)
104+ // {
105+ // selector1: Selector(1),
106+ // selector2: Selector(7)
107+ // }
108+ ```
109+ If you want to get a specific Selector, please use
110+ ``` ts
111+ MY_COLLECTION .getSelector (" selector1" );
112+ ```
113+ instead of
114+ ``` ts
115+ MY_COLLECTION .selectors [" selector1" ]
116+ ```
11117
12- :::
0 commit comments