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

Commit 14eeb12

Browse files
committed
optimized agile instance method docs
1 parent cd7303d commit 14eeb12

File tree

2 files changed

+62
-19
lines changed

2 files changed

+62
-19
lines changed

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

Lines changed: 61 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Here all methods of the `Agile Instance` are described.
1515
## `createState()`
1616

1717
Creates a new [State](../state/Introduction.md),
18-
which gets automatically bound to the [Agile Instance](../agile-instance/Introduction.md) it was created from.
18+
which is automatically bound to the [Agile Instance](../agile-instance/Introduction.md) it was created from.
1919
```ts
2020
const State = App.createState('jeff', {
2121
key: 'dummyState',
@@ -30,6 +30,10 @@ const State = App.createState('jeff', {
3030
| `config` | [StateConfigInterface](../../../../Interfaces.md#stateconfig) | {} | Configuration | No |
3131

3232
### 📄 Return
33+
34+
```ts
35+
State
36+
```
3337
Returns a fresh [State](../state/Introduction.md).
3438

3539

@@ -45,7 +49,7 @@ Returns a fresh [State](../state/Introduction.md).
4549
## `createCollection()`
4650

4751
Creates a new [Collection](../collection/Introduction.md),
48-
which gets automatically bound to the [Agile Instance](../agile-instance/Introduction.md) it was created from.
52+
which is automatically bound to the [Agile Instance](../agile-instance/Introduction.md) it was created from.
4953
```ts {1-4,8-13}
5054
const Collection = App.createCollection({
5155
key: 'dummyCollection',
@@ -70,6 +74,10 @@ const Collection2 = App.createCollection((collection) => ({
7074

7175

7276
### 📄 Return
77+
78+
```ts
79+
Collection
80+
```
7381
Returns a fresh [Collection](../collection/Introduction.md).
7482

7583

@@ -85,7 +93,7 @@ Returns a fresh [Collection](../collection/Introduction.md).
8593
## `createComputed()`
8694

8795
Creates a new [Computed](../computed/Introduction.md),
88-
which gets automatically bound to the [Agile Instance](../agile-instance/Introduction.md) it was created from.
96+
which is automatically bound to the [Agile Instance](../agile-instance/Introduction.md) it was created from.
8997
```ts {1,5-7}
9098
const Computed = App.createComputed(() => {/* Computed Method */}, [/* hard coded deps */])
9199

@@ -105,6 +113,10 @@ const ComputedWithConfig = App.createComputed(() => {/* Computed Method */}, {
105113
| `deps` | Array<Observer \| State \| Event \| Group\> | [] | Dependencies of Computed | No |
106114

107115
### 📄 Return
116+
117+
```ts
118+
Computed
119+
```
108120
Returns a fresh [Computed](../computed/Introduction.md).
109121

110122

@@ -120,7 +132,7 @@ Returns a fresh [Computed](../computed/Introduction.md).
120132
## `createEvent()`
121133

122134
Creates a new [Event](../event/Introduction.md),
123-
which gets automatically bound to the [Agile Instance](../agile-instance/Introduction.md) it was created from.
135+
which is automatically bound to the [Agile Instance](../agile-instance/Introduction.md) it was created from.
124136
```ts
125137
const Event = App.createEvent({
126138
key: 'dummyEvent',
@@ -135,6 +147,10 @@ const Event = App.createEvent({
135147

136148

137149
### 📄 Return
150+
151+
```ts
152+
Events
153+
```
138154
Returns a fresh [Event](../event/Introduction.md).
139155

140156

@@ -149,10 +165,18 @@ Returns a fresh [Event](../event/Introduction.md).
149165

150166
## `integrate()`
151167

152-
Allows us to integrate AgileTs into nearly any [Framework/Integration](../integration/Introduction.md).
153-
For instance in case of [React](https://reactjs.org/), AgileTs offers a [React Integration](../integration/Introduction.md),
154-
which allows us to integrate it into AgileTs.
155-
```ts {29}
168+
With `integrate()` we can integrate any Framework [Integration](../integration/Introduction.md) into AgileTs.
169+
An Integration simply tells AgileTs, how it has to mutate a specific Component,
170+
whenever a State changes. In order binding States to Components and thus be reactive,
171+
each Framework using AgileTs needs an Integration for AgileTs.
172+
For instance to use AgileTs in a [React](https://reactjs.org/) environment,
173+
we have to integrate a React Integration into AgileTs.
174+
```ts
175+
App.integrate(reactIntegration);
176+
```
177+
To give you some reference, how such an Integration might look like.
178+
Here is the React Integration:
179+
```ts
156180
const reactIntegration = new Integration<typeof React, AgileReactComponent>({
157181
key: 'react',
158182
frameworkInstance: React,
@@ -177,11 +201,7 @@ const reactIntegration = new Integration<typeof React, AgileReactComponent>({
177201
});
178202

179203
// Each initialIntegraion gets integrated into AgileTs automatically during initialation
180-
// Note: Only useful if you create your own integration
181204
Agile.initialIntegrations.push(reactIntegration);
182-
183-
// Or we integrate it manually (mostly the case if the auto integration doesn't work)
184-
App.integrate(reactIntegration);
185205
```
186206

187207
### 📭 Props
@@ -191,6 +211,10 @@ App.integrate(reactIntegration);
191211
| `integration` | [Integration](../integration/Introduction.md) | undefined | Integration that gets registered/integrated into AgileTs | Yes |
192212

193213
### 📄 Return
214+
215+
```ts
216+
Agile
217+
```
194218
Returns the [Agile Instance](./Introduction.md) it was called from
195219

196220

@@ -204,10 +228,14 @@ Returns the [Agile Instance](./Introduction.md) it was called from
204228

205229

206230
## `hasIntegration()`
231+
207232
Checks if AgileTs has any registered [Integration](../integration/Introduction.md).
208233

209234
### 📄 Return
210-
`boolean`
235+
236+
```ts
237+
boolean
238+
```
211239

212240

213241

@@ -221,7 +249,8 @@ Checks if AgileTs has any registered [Integration](../integration/Introduction.m
221249

222250
## `createStorage()`
223251

224-
Creates a new [Storage](../storage/Introduction.md).
252+
Creates a new [Storage](../storage/Introduction.md) Interface for AgileTs,
253+
which allows AgileTs to work with the Storage, the Interface represents.
225254
```ts
226255
const Storage = App.createStorage({
227256
key: 'dummyStorage',
@@ -232,7 +261,8 @@ const Storage = App.createStorage({
232261
}
233262
})
234263
```
235-
To register a newly created Storage, we use the [registerStorage](#registerstorage) function.
264+
Such Storage can be registered in AgileTs with the [registerStorage()](#registerstorage) method.
265+
After a successful registration we can store/[persist](../state/Methods.md#persist) any State in the Storage.
236266

237267
### 📭 Props
238268

@@ -242,6 +272,10 @@ To register a newly created Storage, we use the [registerStorage](#registerstora
242272
| `methods` | [StorageMethodsInterface](../../../../Interfaces.md#storagemethods) | {} | Methods with which the Storage get mutated | Yes |
243273

244274
### 📄 Return
275+
276+
```ts
277+
Storage
278+
```
245279
Returns a fresh [Storage](../storage/Introduction.md).
246280

247281

@@ -256,9 +290,10 @@ Returns a fresh [Storage](../storage/Introduction.md).
256290

257291
## `registerStorage()`
258292

259-
Adds a new [Storage](../storage/Introduction.md) to AgileTs,
260-
which later can store persisted Instances (`.persist()`).
293+
Registers a new [Storage](../storage/Introduction.md) Interface to AgileTs,
294+
which later can store persisted Instances ([`.persist()`](../state/Methods.md)).
261295
The [Local Storage](https://developer.mozilla.org/de/docs/Web/API/Window/localStorage) is registered by default.
296+
Below you can see how the localStorage is registered internally.
262297
```ts {13}
263298
// Here we create our Storage
264299
const _localStorage = new Storage({
@@ -282,6 +317,10 @@ App.register(_localStorage, { default: true });
282317
| `integration` | [Integration](../integration/Introduction.md) | undefined | Integration that gets registered/integrated into AgileTs | Yes |
283318

284319
### 📄 Return
320+
321+
```ts
322+
Agile
323+
```
285324
Returns the [Agile Instance](./Introduction.md) it was called from
286325

287326

@@ -295,8 +334,12 @@ Returns the [Agile Instance](./Introduction.md) it was called from
295334

296335

297336
## `hasStorage()`
337+
298338
Checks if AgileTs has any registered [Storage](../storage/Introduction.md).
299339
If AgileTs couldn't find any Storage, we aren't able to use the `.persist()` functionality in any Agile Sub Instance.
300340

301341
### 📄 Return
302-
`boolean`
342+
343+
```ts
344+
boolean
345+
```

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ so we always have to add `.everywhere()` or `.fromGroups()`.
13301330

13311331
| Prop | Type | Default | Description | Required |
13321332
|----------------------|-----------------------------------------------------------------------------------|------------|-----------------------------------------------------------------------------------------------|----------|
1333-
| `itemKeys` | number \| string | Array<number \| string\> | undefined | itemKey/s that get removed | Yes |
1333+
| `itemKeys` | number \| string | Array<number \| string\> | undefined | itemKey/s that get removed | Yes |
13341334

13351335
### 📄 Return
13361336

0 commit comments

Comments
 (0)