Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

Commit eb91ec3

Browse files
authored
Merge pull request #78 from agile-ts/develop
updated docusaurus
2 parents 6b27b55 + 9470dcd commit eb91ec3

File tree

16 files changed

+509
-321
lines changed

16 files changed

+509
-321
lines changed

docs/packages/core/Introduction.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ It contains the main Instance of AgileTs, called [`Agile Class`](./features/agil
2626
```ts
2727
const App = new Agile();
2828
```
29-
In summary, the most important tasks of the `Agile Class` are to:
30-
- manage `Agile Sub Instances`, like [States](./features/state/Introduction.md), ..
31-
- ingest changes into the `runtime`
32-
- trigger rerender in Integrations like [React](../react/Introduction.md)
33-
- store values in any [Storage](./features/storage/Introduction.md)
29+
In summary the main tasks of the `AgileClass` are to:
30+
- queuing `Agile Sub Instance` changes in the `runtime` and preventing race conditions
31+
- provide configuration object
32+
- update/rerender subscribed Components through Integrations like the [React Integration](../react/Introduction.md)
33+
- Integrating with persistent [Storage](./features/storage/Introduction.md)
3434

35-
Each application using AgileTs needs the `core` package
35+
Each application using AgileTs needs the `core` package installed
3636
and has to instantiate a `Agile Class` often called `App`.
3737
To get some inspiration where to instantiate the `Agile Class`, check out the [Style Guide](../../main/StyleGuide.md) Section.
3838
Besides, the `Agile Class` the `core` holds some other useful classes,
3939
which represent the actual features of AgileTs, since the `Agile Class`
40-
is mostly used internally.
40+
is mostly used internally as interface to Storages and Frameworks.
4141

4242
### ⚡️ [State](./features/state/Introduction.md)
4343
A State holds an Information that we need to remember at a later point in time.

docs/packages/core/features/agile-instance/Introduction.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ The `Agile Class` is the main Instance of AgileTs and should be unique to our ap
1616
```ts
1717
const App = new Agile();
1818
```
19-
It can be seen as our application manager. Each `Agile Sub Instance` (ASI) holds a reference
20-
to the `Agile Class` and depends on its functionalities. <br/>
21-
For reference here are some `Agile Sub Instances` (ASI):
19+
It can be seen as the interface to any Storage, or the Frameworks AgileTs is implemented in like React.
20+
In addition, it manages the changes of `Agile Sub Instances` to prevent race conditions.
21+
Each `Agile Sub Instance` (ASI) holds a reference to the `Agile Class` and depends on its functionalities.
22+
Furthermore, ASI's are created with the help of an instantiated `Agile Class`.
23+
For reference here are some `Agile Sub Instances` (ASI) created with an `Agile Instance` called `App`:
2224

2325
- [State](../state/Introduction.md)
2426
```ts
@@ -38,11 +40,10 @@ For reference here are some `Agile Sub Instances` (ASI):
3840
```
3941

4042
In summary the main tasks of the `AgileClass` are to:
41-
- manage Agile Sub Instances, like [States](../state/Introduction.md), ..
42-
- ingest changes into the Runtime (queue system for managing ASI mutations)
43+
- queuing `Agile Sub Instance` changes in the `runtime` and preventing race conditions
4344
- provide configuration object
44-
- trigger rerender on Integrations like [React](../../../react/Introduction.md)
45-
- store values in any [Storage](../storage/Introduction.md)
45+
- update/rerender subscribed Components through Integrations like the [React Integration](../../../react/Introduction.md)
46+
- Integrating with persistent [Storage](../storage/Introduction.md)
4647

4748
## 📭 Props
4849

@@ -82,7 +83,6 @@ const App = new Agile({
8283
```
8384
To find out more about possible configuration options, checkout the [CreateLoggerConfigInterface](../../../../Interfaces.md#createloggerconfig).
8485

85-
8686
#### `localStorage`
8787

8888
Defines whether AgileTs should create an interface to the `localStorage` for us or not.

docs/packages/core/features/collection/Introduction.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Most methods we use to modify, mutate and access the Collection are chainable.
3333
MY_COLLECTION.collect({id: 1, name: "jeff"}).persist().removeGroup('myGroup').reset();
3434
```
3535

36-
### 🔨 Use case
3736

37+
### 🔨 Use case
3838
For instance a Collection can be used to remember a flexible array of Todo objects.
3939
```ts
4040
const TODOS = App.createCollection();
@@ -50,16 +50,19 @@ We do that to keep track of which todo relates to which user.
5050
Now that we `cleaned our bathroom`,
5151
we remove the todo related to the id `1` from the Collection and all Groups (-> everywhere).
5252

53+
5354
### ⛳️ Sandbox
5455
Test the Collection yourself. It's only one click away. Just select your preferred Framework below.
5556
- [React](https://codesandbox.io/s/agilets-first-collection-uyi9g)
5657
- Vue (coming soon)
5758
- Angular (coming soon)
5859

60+
5961
## 🗂 Collection Classes
6062

6163
A Collection consists of several classes, all of which play an important role.
6264

65+
6366
### 🔹 Item
6467

6568
Each Data Object we add to our Collection (for example, with the `collect()` method)
@@ -109,6 +112,7 @@ myItem.patch({name: "frank"}); // Update property 'name' in Item
109112
myItem.undo(); // Undo latest change
110113
```
111114

115+
112116
### 👨‍👧‍👦 [Group](./group/Introduction.md)
113117

114118
Often applications need to categorize and preserve the ordering of structured data.
@@ -143,6 +147,7 @@ POSTS.collect(user.posts, user.id);
143147
In the above code snippet, we have two Collections, one for users and another for posts.
144148
We can collect posts specific to a user and group them automatically by the user's id.
145149

150+
146151
### 🔮 [Selector](./selector/Introduction.md)
147152

148153
Sometimes we need access to one specific Item of a Collection in the long term.
@@ -158,9 +163,10 @@ mySelector.patch({name: "frank"}); // Update property 'name' in Item
158163
```
159164
For instance, a Selector finds its use, to select the currently logged-in user from a User Collection.
160165
```ts
161-
USERS.select(/* current logged-in userId */);
166+
const CURRENT_USER = USERS.select(/* current logged-in userId */);
162167
```
163168

169+
164170
## 📭 Props
165171

166172
```ts
@@ -263,15 +269,16 @@ which gives us much more freedom in configuring them.
263269
<br/>
264270

265271
#### `key`
266-
The name/key is an optional property that is used to identify a specific Collection.
267-
Such key is pretty useful during debug sessions or if we persist our Collection,
268-
it automatically uses the Collection `key` as persist key.
269-
We recommend giving each Collection a unique `key`, since it has only advantages.
272+
The optional property `key/name` should be a unique `string/number` to identify the Collection later.
270273
```ts
271274
const MY_COLLECTION = App.createCollection({
272275
key: "myKey"
273276
});
274277
```
278+
We recommend giving each Collection a unique `key`, since it has only advantages:
279+
- helps us during debug sessions
280+
- makes it easier to identify the Collection
281+
- no need for separate persist Key
275282

276283
<br/>
277284

@@ -310,6 +317,7 @@ const MY_COLLECTION = App.createCollection({
310317
});
311318
```
312319

320+
313321
## 🟦 Typescript
314322

315323
A `Collection` is almost 100% typesafe and takes an optional generic type for type safety

docs/packages/core/features/collection/Properties.md

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ Here are valuable properties of the `Collection Class` listed.
1212
:::
1313

1414
## `agileInstance`
15-
Agile Instance to which the Collection belongs
15+
16+
The [`agileInstance`](../agile-instance/Introduction.md) to which the Collection belongs.
1617
```ts
17-
MY_STATE.agileInstance(); // Returns a Agile Instance
18+
MY_COLLECTION.agileInstance(); // Returns a Agile Instance
1819
```
19-
Note that it is stored as a function in the Collection, to avoid endless deep classes.
20+
Be aware that the `agileInstance` property is of the type function,
21+
to avoid endless deep classes.
2022

2123

2224

@@ -29,12 +31,17 @@ Note that it is stored as a function in the Collection, to avoid endless deep cl
2931

3032

3133
## `key`
32-
Current key/name of the Collection.
33-
It is used to uniquely identify the Collection.
34-
Besides getting the `key`, we can also assign a new `key` with help of this property.
35-
```ts
36-
MY_COLLECTION.key = "myCoolCollection";
37-
MY_COLLECTION.key; // Returns 'myCoolCollection'
34+
35+
The current `key/name` of the Collection,
36+
which is used to uniquely identify it.
37+
```ts {2}
38+
const MY_COLLECTION = App.createCollection({key: 'jeffKey'});
39+
MY_COLLECTION.key; // Returns 'jeffKey'
40+
```
41+
Besides, accessing the `key`, we can also assign a new `key` through this property.
42+
```ts {1}
43+
MY_STATE.key = "myCoolState";
44+
MY_STATE.key; // Returns 'myCoolState'
3845
```
3946

4047

@@ -48,13 +55,14 @@ MY_COLLECTION.key; // Returns 'myCoolCollection'
4855

4956

5057
## `size`
51-
How many Items are stored in the Collection right now.
58+
59+
Represents how many Items are currently stored in the Collection.
5260
```ts {3}
5361
MY_COLLECTION.collect({id: 1, name: "jeff"});
5462
MY_COLLECTION.collect({id: 5, name: "frank"});
5563
MY_COLLECTION.size; // Returns 2
5664
```
57-
Be aware that placeholder Items doesn't get counted.
65+
Placeholder Items doesn't get counted.
5866

5967

6068

@@ -67,7 +75,8 @@ Be aware that placeholder Items doesn't get counted.
6775

6876

6977
## `data`
70-
All Items of the Collection are stored here.
78+
79+
The `data` object holds all Items of the Collection.
7180
```ts {3}
7281
MY_COLLECTION.collect({id: 1, name: "jeff"});
7382
MY_COLLECTION.collect({id: 5, name: "frank"});
@@ -77,23 +86,14 @@ MY_COLLECTION.data; // Returns (see below)
7786
// 5: Item({id: 5, name: "frank"})
7887
// }
7988
```
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.
8993
```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
9596
```
96-
Because the `data` property isn't thought to be used in the outer world.
9797

9898

9999

@@ -106,11 +106,12 @@ Because the `data` property isn't thought to be used in the outer world.
106106

107107

108108
## `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).
110111
```ts {1,3}
111-
MY_COLLECTION.isPersisted; // Returns false
112+
MY_COLLECTION.isPersisted; // Returns 'false'
112113
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
114115
```
115116

116117

@@ -124,7 +125,8 @@ MY_COLLECTION.isPersisted; // Returns true (if the persisting was successfull)
124125

125126

126127
## `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.
128130
```ts {3}
129131
MY_COLLECTION.createGroup("group1", [1, 2, 3]);
130132
MY_COLLECTION.createGroup("group2", [1, 7, 4]);
@@ -134,13 +136,13 @@ MY_COLLECTION.groups; // Returns (see below)
134136
// group2: Group([1, 7, 4])
135137
// }
136138
```
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.
143+
```ts {1}
144+
MY_COLLECTION.getGroup(1); // Good pattern
145+
MY_COLLECTION.groups[1]; // Bad pattern
144146
```
145147

146148

@@ -154,22 +156,23 @@ MY_COLLECTION.groups["group1"]
154156

155157

156158
## `selectors`
157-
Here all [Selectors](./selector/Introduction.md) of the Collection are stored.
159+
160+
All [Selectors](./selector/Introduction.md) of the Collection are stored in the `selectors` property.
158161
```ts {3}
159-
MY_COLLECTION.createGroup("selector1", 1);
160-
MY_COLLECTION.createGroup("selector2", 7);
161-
MY_COLLECTION.groups; // Returns (see below)
162+
MY_COLLECTION.createSelector("selector1", 1);
163+
MY_COLLECTION.createSelector("selector2", 7);
164+
MY_COLLECTION.selectors; // Returns (see below)
162165
// {
163166
// selector1: Selector(1),
164167
// selector2: Selector(7)
165168
// }
166169
```
167-
If we want to get access to one specific Selector, we should use
168-
```ts
169-
MY_COLLECTION.getSelector("selector1");
170-
```
171-
instead of
172-
```ts
173-
MY_COLLECTION.selectors["selector1"]
170+
We do not recommend accessing the `selectors` object directly in your code,
171+
as it is intended for internal use and shouldn't be used outside the AgileTs codebase.
172+
The Collection provides all the methods to access the `selectors` object without further thinking.
173+
For example, to get one specific Selector, we should use the `getSelector()` method.
174+
```ts {1}
175+
MY_COLLECTION.getSelector(1); // Good pattern
176+
MY_COLLECTION.selector[1]; // Bad pattern
174177
```
175178

0 commit comments

Comments
 (0)