You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 15, 2025. It is now read-only.
How many Items are stored in the Collection right now.
58
+
59
+
Represents how many Items are currently stored in the Collection.
52
60
```ts {3}
53
61
MY_COLLECTION.collect({id: 1, name: "jeff"});
54
62
MY_COLLECTION.collect({id: 5, name: "frank"});
55
63
MY_COLLECTION.size; // Returns 2
56
64
```
57
-
Be aware that placeholder Items doesn't get counted.
65
+
Placeholder Items doesn't get counted.
58
66
59
67
60
68
@@ -67,7 +75,8 @@ Be aware that placeholder Items doesn't get counted.
67
75
68
76
69
77
## `data`
70
-
All Items of the Collection are stored here.
78
+
79
+
The `data` object holds all Items of the Collection.
71
80
```ts {3}
72
81
MY_COLLECTION.collect({id: 1, name: "jeff"});
73
82
MY_COLLECTION.collect({id: 5, name: "frank"});
@@ -77,23 +86,14 @@ MY_COLLECTION.data; // Returns (see below)
77
86
// 5: Item({id: 5, name: "frank"})
78
87
// }
79
88
```
80
-
We recommend using the `getAllItems` function to get assess to all Items,
81
-
```ts {1}
82
-
MY_COLLECTION.getAllItems(); // Returns (see below)
83
-
// [
84
-
// Item({id: 1, name: "jeff"}),
85
-
// Item({id: 5, name: "frank"})
86
-
// ]
87
-
```
88
-
or the `default Group`.
89
+
We do not recommend accessing the `data` object directly in your code,
90
+
as it is intended for internal use and shouldn't be used outside the AgileTs codebase.
91
+
The Collection provides all the methods to access the `data` object without further thinking.
92
+
For example, to get one specific Item, we should use the `getItem()` method.
89
93
```ts {1}
90
-
MY_COLLECTION.getGroup(MY_COLLECTION.config.defaultGroupKey).items; // Returns (see below)
91
-
// [
92
-
// Item({id: 1, name: "jeff"}),
93
-
// Item({id: 5, name: "frank"})
94
-
// ]
94
+
MY_COLLECTION.getItem(1); // Good pattern
95
+
MY_COLLECTION.data[1]; // Bad pattern
95
96
```
96
-
Because the `data` property isn't thought to be used in the outer world.
97
97
98
98
99
99
@@ -106,11 +106,12 @@ Because the `data` property isn't thought to be used in the outer world.
106
106
107
107
108
108
## `isPersisted`
109
-
If the State Value got successfully persisted into an external Storage like the [Local Storage](https://developer.mozilla.org/de/docs/Web/API/Window/localStorage).
109
+
110
+
If the Collection `value` is stored in an external Storage like the [Local Storage](https://developer.mozilla.org/de/docs/Web/API/Window/localStorage).
110
111
```ts {1,3}
111
-
MY_COLLECTION.isPersisted; // Returns false
112
+
MY_COLLECTION.isPersisted; // Returns 'false'
112
113
MY_COLLECTION.persist();
113
-
MY_COLLECTION.isPersisted; // Returns true (if the persisting was successfull)
114
+
MY_COLLECTION.isPersisted; // Returns 'true' if the persist was successful
114
115
```
115
116
116
117
@@ -124,7 +125,8 @@ MY_COLLECTION.isPersisted; // Returns true (if the persisting was successfull)
124
125
125
126
126
127
## `groups`
127
-
Here all [Groups](./group/Introduction.md) of the Collection are stored.
128
+
129
+
All [Groups](./group/Introduction.md) of the Collection are stored in the `groups` property.
128
130
```ts {3}
129
131
MY_COLLECTION.createGroup("group1", [1, 2, 3]);
130
132
MY_COLLECTION.createGroup("group2", [1, 7, 4]);
@@ -134,13 +136,13 @@ MY_COLLECTION.groups; // Returns (see below)
134
136
// group2: Group([1, 7, 4])
135
137
// }
136
138
```
137
-
If we want to get access to one specific Group, we should use
138
-
```ts
139
-
MY_COLLECTION.getGroup("group1");
140
-
```
141
-
instead of
142
-
```ts
143
-
MY_COLLECTION.groups["group1"]
139
+
We do not recommend accessing the `groups` object directly in your code,
140
+
as it is intended for internal use and shouldn't be used outside the AgileTs codebase.
141
+
The Collection provides all the methods to access the `groups` object without further thinking.
142
+
For example, to get one specific Group, we should use the `getGroup()` method.
0 commit comments