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

Commit fb24ebc

Browse files
authored
Merge pull request #24 from agile-ts/develop
Develop
2 parents d49a141 + 0272297 commit fb24ebc

File tree

10 files changed

+615
-219
lines changed

10 files changed

+615
-219
lines changed

docs/Interfaces.md

Lines changed: 395 additions & 146 deletions
Large diffs are not rendered by default.

docs/examples/react/All.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const CodeSandBoxEmbed = ({ uri, height }) => (
1515
<iframe
1616
src={`https://codesandbox.io/embed/${uri}?fontsize=14&hidenavigation=0&theme=dark&view=preview`}
1717
title={"Code Sandbox"}
18-
style={{width: "100%", height: height || 500, borderRadius: 4, overflow: "hidden"}}
18+
style={{width: "100%", height: height || 500, borderRadius: 4, borderColor: "#6c69a0", overflow: "hidden"}}
1919
allow={
2020
"geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
2121
}
@@ -25,11 +25,11 @@ export const CodeSandBoxEmbed = ({ uri, height }) => (
2525
/>
2626
);
2727

28-
# First State
28+
## 😎 First State
2929

3030
<CodeSandBoxEmbed uri={"agilets-first-state-f12cz"}/>
3131

3232

33-
# Multieditor
33+
## 📝 Multieditor
3434

3535
<CodeSandBoxEmbed uri={"multieditor-yxt4x"} height={800}/>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ Here are some examples of Agile Sub Instances (ASI):
3838

3939
These ASI's are created with the help of an `Agile Instance` and get automatically bound to it.
4040
In summary, the main tasks of an instantiated `Agile Class` (Agile Instance) are to:
41-
- manage and store Agile Sub Instances ([State](./features/state/Introduction.md), ..)
41+
- manage and store Agile Sub Instances ([State](../state/Introduction.md), ..)
4242
- ingest changes into the Runtime
43-
- trigger rerender on Integrations like [React](../react/Introduction.md)
44-
- permanently save values in any [Storage](./features/storage/Introduction.md)
43+
- trigger rerender on Integrations like [React](../../../react/Introduction.md)
44+
- permanently save values in any [Storage](../storage/Introduction.md)
4545

4646
Be aware that each application using AgileTs should only have **one** `Agile Instance`.
4747

@@ -119,4 +119,4 @@ The `Agile Class` is almost 100% typesafe.
119119
We can instantiate the `Agile Class` where ever we want.
120120
Directly in our Component, in a separate file or on paper.
121121
It doesn't matter as long as we can work with it.
122-
There are a few [Style Guides](../../../../main/StyleGuide.md) which might help us with such hard decision.
122+
There are a few [Style Guides](../../../../main/StyleGuide.md) which might help us with such hard decision.

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ USERS.select(/* current logged-in userId */);
104104

105105
## 📭 Props
106106

107+
```ts
108+
App.createCollection(config);
109+
```
110+
111+
### `config`
112+
107113
Our `Collection` takes, an optional configuration object as its only property.
108114
There are two different ways to configure our Collection with these object.
109115

@@ -144,7 +150,9 @@ export interface CreateCollectionConfigInterface<DataType = DefaultItem> {
144150
}
145151
```
146152

147-
### `groups`
153+
<br/>
154+
155+
#### `groups`
148156
Here we define the initial [Groups](#groups) of our Collection.
149157
There are two ways of doing this.
150158
The first one is to pass an Array of Group Names.
@@ -168,7 +176,9 @@ const MY_COLLECTION = App.createCollection((collection) => ({
168176
With help of the Collection, we are able to 'instantiate' the Groups on our own,
169177
which gives us much more freedom configuring these.
170178

171-
### `selectors`
179+
<br/>
180+
181+
#### `selectors`
172182
Here we define the initial [Selectors](#selectors) of our Collection.
173183
As with the `groups` property, there are also 2 ways to define the Selector here.
174184
The first one is to pass an Array of Selector Names.
@@ -192,7 +202,9 @@ const MY_COLLECTION = App.createCollection((collection) => ({
192202
With help of the Collection, we are able to 'instantiate' the Selectors on our own,
193203
which gives us much more freedom configuring these.
194204

195-
### `key`
205+
<br/>
206+
207+
#### `key`
196208
The Key/Name is an optional property, that gets used to identify our Collection.
197209
This is pretty useful during debug sessions or if we persist our Collection,
198210
where it automatically uses the `key` as persist key.
@@ -203,7 +215,9 @@ const MY_COLLECTION = App.createCollection({
203215
});
204216
```
205217

206-
### `primaryKey`
218+
<br/>
219+
220+
#### `primaryKey`
207221
The primaryKey is used to define which property in the collected Data gets used as primaryKey.
208222
By default, it is `id`. Each collected Data needs one primaryKey otherwise, we are not able
209223
to properly identify this Data later.
@@ -217,7 +231,9 @@ MY_COLLECTION.collect({key: 1, name: "hans"});
217231
// primary Key ----------
218232
```
219233

220-
### `defaultGroupKey`
234+
<br/>
235+
236+
#### `defaultGroupKey`
221237
The defaultGroupKey is used to define the name/key of the default Group.
222238
The default Group represents all Items of the Collection.
223239
By default, what a wonder is it `default`.
@@ -227,7 +243,9 @@ const MY_COLLECTION = App.createCollection({
227243
});
228244
```
229245

230-
### `initialData`
246+
<br/>
247+
248+
#### `initialData`
231249
The initial Data of our Collection.
232250
```ts
233251
const MY_COLLECTION = App.createCollection({

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

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,147 @@ Returns the [Collection](./Introduction.md) it was called on.
4545

4646

4747

48-
`Group()`
48+
## `Group()`
49+
50+
Creates a new Group, without binding it properly to the Collection.
51+
This function is intended to be used in the `Collection Config`.
52+
```ts {3}
53+
App.createCollection((collection) => ({
54+
groups: {
55+
myGroup: collection.Group(["item1", "item2"])
56+
}
57+
}))
58+
```
59+
For creating groups in general we recommend using `createGroup`,
60+
because it binds the Group properly to the Collection.
61+
62+
### 📭 Props
63+
64+
| Prop | Type | Default | Description | Required |
65+
|----------------|---------------------------------------------------------------------------|------------|-------------------------------------------------------|----------|
66+
| `initialItems` | Array<string \| number> | [] | Initial ItemKeys of the Group | No |
67+
| `config` | [GroupConfig](../../../../Interfaces.md#groupconfig) | {} | Configuration | No |
68+
69+
### 📄 Return
70+
Returns a fresh [Group](./group/Introduction.md).
71+
72+
73+
74+
<br />
75+
76+
---
77+
78+
<br />
79+
80+
81+
82+
## `Selector()`
83+
84+
Creates a new Selector, without binding it properly to the Collection.
85+
This function is intended to be used in the `Collection Config`.
86+
```ts {3}
87+
App.createCollection((collection) => ({
88+
selectors: {
89+
mySelector: collection.Selector("item1")
90+
}
91+
}))
92+
```
93+
For creating selectors in general we recommend using `createSelector`,
94+
because it binds the Selector properly to the Collection.
95+
96+
### 📭 Props
97+
98+
| Prop | Type | Default | Description | Required |
99+
|----------------|---------------------------------------------------------------------------|------------|-------------------------------------------------------|----------|
100+
| `initialKey` | string \| number | undefined | Key of Item that the Selector represents | No |
101+
| `config` | [SelectorConfig](../../../../Interfaces.md#selectorconfig) | {} | Configuration | No |
102+
103+
### 📄 Return
104+
Returns a fresh [Selector](./selector/Introduction.md).
105+
106+
107+
108+
<br />
109+
110+
---
111+
112+
<br />
113+
114+
115+
116+
## `initSelectors()`
117+
118+
:::warning
119+
120+
No public function! Is public because of testing hehe..
121+
122+
:::
123+
124+
125+
126+
<br />
127+
128+
---
129+
130+
<br />
131+
132+
133+
134+
## `initGroups()`
135+
136+
:::warning
137+
138+
No public function! Is public because of testing hehe..
139+
140+
:::
141+
142+
143+
144+
<br />
145+
146+
---
147+
148+
<br />
149+
150+
151+
152+
## `collect()`
153+
154+
Allows us to collect Data and add it to our Collection.
155+
```ts
156+
MY_COLLECTION.collect({id: 1, name: "jeff"}); // Collect one Data
157+
MY_COLLECTION.collect([{id: 9, name: "hans"}, {id: 22, name: "frank"}]); // Collect multiple Datas
158+
```
159+
**Each Data needs one `primaryKey` to properly be identified later.**
160+
In the above example, the `primaryKey` property is _'id'_, but we can change it in the `Collection Config`.
161+
If one Data Object contains a `primaryKey` which already exists,
162+
the existing Data will be overwritten by default.
163+
164+
To quickly add Data to specific Groups,
165+
the collect method takes `groupKeys` beside the to collect Data.
166+
A Group is like an interface to the Data of a Collection.
167+
Each collected Data will be added to the _'default'_ Group by default.
168+
```ts
169+
MY_COLLECTION.collect({id: 1, name: "jeff"}, ["group1", "group2"]);
170+
```
171+
For each not existing passed `groupKey`, a new Group will automatically be created.
172+
For instance if the _'group1'_ from the above example doesn't exist,
173+
a Group with the initial itemKeys ('[1]'), and the key 'group1' gets created.
174+
175+
### 📭 Props
176+
177+
| Prop | Type | Default | Description | Required |
178+
|----------------|---------------------------------------------------------------------------|------------|-------------------------------------------------------|----------|
179+
| `data` | DataType \| Array<DataType\> (DataType = Object) | undefined | Data which gets added to the Collection | No |
180+
| `groupKeys` | string \| number | [] | Keys of Groups to which the Data gets added | No |
181+
| `config` | [CollectConfig](../../../../Interfaces.md#collectconfig) | {} | Configuration | No |
182+
183+
### 📄 Return
184+
Returns the [Collection](./Introduction.md) it was called on.
185+
186+
187+
188+
189+
49190

50191

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

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ Test the State yourself, it's only one click away. Just select your preferred Fr
5454

5555
## 📭 Props
5656

57+
```ts
58+
App.createState(initialValue, config);
59+
```
60+
61+
### `initialValue`
62+
63+
The first Value which gets assigned to our State.
64+
```ts {1}
65+
const MY_STATE = App.createState("hello there");
66+
MY_STATE.value; // Returns 'hello there'
67+
MY_STATE.initialStateValue; // Returns 'hello there'
68+
```
69+
70+
### `config`
71+
5772
Our `State` takes, beside the initial value an optional configuration object.
5873
```ts
5974
const MY_STATE = App.createState("myInitialValue", {
@@ -71,7 +86,9 @@ export interface StateConfigInterface {
7186
}
7287
```
7388

74-
### `key`
89+
<br/>
90+
91+
#### `key`
7592
The Key/Name is an optional property, that gets used to identify our State.
7693
This is pretty useful during debug sessions or if we persist our State,
7794
where it automatically uses the `key` as persist key.
@@ -82,7 +99,9 @@ const MY_STATE = App.createState("myInitialValue", {
8299
});
83100
```
84101

85-
### `dependents`
102+
<br/>
103+
104+
#### `dependents`
86105

87106
:::info
88107

@@ -99,7 +118,9 @@ const MY_STATE = App.createState("myInitialValue", {
99118
});
100119
```
101120

102-
### `isPlaceholder`
121+
<br/>
122+
123+
#### `isPlaceholder`
103124

104125
:::info
105126

@@ -120,8 +141,10 @@ MY_STATE.exists(); // false
120141
## 🟦 Typescript
121142

122143
`State` is almost 100% typesafe and takes an optional generic type for type safety.
123-
```ts
144+
```ts {1}
124145
const MY_STATE = App.createState<string>("Hello World");
146+
MY_STATE.set(1); // Error
147+
MY_STATE.set("hello space"); // Success
125148
```
126149
This type defines the type of the State Value.
127150
Javascript users can also get rudimentary typesafe, with the `type` function.

0 commit comments

Comments
 (0)