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

Commit 6cb4287

Browse files
committed
removed App.x
1 parent 4b52cdb commit 6cb4287

File tree

19 files changed

+100
-115
lines changed

19 files changed

+100
-115
lines changed

docs/Interfaces.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ or _updating the persisted State value in the corresponding external Storage_.
188188

189189
When set to `true`, the Job is forced through the `runtime` no matter what happens.
190190
```ts {7}
191-
const MY_STATE = App.createState('myValue');
191+
const MY_STATE = createState('myValue');
192192

193193
// Won't be executed by the runtime because the State value hasn't changed
194194
MY_STATE.set('myValue');
@@ -275,7 +275,7 @@ export interface PatchConfigInterface extends StateIngestConfigInterface {
275275

276276
If `true`, new properties are added to the State value, although they might not yet be present there.
277277
```ts {2,4}
278-
const MY_STATE = App.createState({id: 1, name: "frank"});
278+
const MY_STATE = createState({id: 1, name: "frank"});
279279
MY_STATE.patch({location: "Germany"}, {addNewProperties: false});
280280
MY_STATE.value; // Returns {id: 1, name: "frank"}
281281
MY_STATE.patch({location: "Germany"}, {addNewProperties: true});
@@ -395,7 +395,7 @@ We recommend giving each Group a unique `key` since it has only advantages:
395395

396396
Defines whether the Group is a `placeholder`.
397397
```ts
398-
const MY_GROUP = App.createGroup([1, 2, 3], {
398+
const MY_GROUP = createGroup([1, 2, 3], {
399399
isPlaceholder: true
400400
});
401401

@@ -522,7 +522,7 @@ if we collect a data object with an already existing `primaryKey` in order to up
522522

523523
If `true`, the passed data object is merged into the found Item data instead of overwriting it entirely.
524524
```ts {6,9}
525-
const MY_COLLECTION = App.createCollection({
525+
const MY_COLLECTION = createCollection({
526526
initialData: [{id: 1, name: 'frank', age: 10}]
527527
});
528528

docs/main/StyleGuides.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,16 @@ and define all [Agile Sub Instances](../main/Introduction.md#agile-sub-instance)
7777
In addition, all actions (`updateTodo()`, `toogleTodo()`, ..)
7878
and if you are using Typescript interfaces (`TodoInterface`) are located here.
7979
```ts title="store.ts"
80-
import { Agile, assignSharedAgileInstance } from "@agile-ts/core";
81-
import reactIntegration from "@agile-ts/react";
80+
import { createCollection } from "@agile-ts/core";
8281

8382
export interface TodoInterface {
8483
id: number;
8584
text: string;
8685
done: boolean;
8786
}
8887

89-
// Create Agile Instance
90-
const App = new Agile().integrate(reactIntegration);
91-
9288
// Create Collection (a dynamic set of States)
93-
export const MY_TODOS = App.createCollection<TodoInterface>({
89+
export const MY_TODOS = createCollection<TodoInterface>({
9490
key: "todos"
9591
}).persist(); // perist does store the Collection in the Local Storage
9692

@@ -309,15 +305,15 @@ and contains the [Agile Sub Instances](../main/Introduction.md#agile-sub-instanc
309305
These Agile Sub Instances can and should then only be modified by the actions ([actions.ts](#1-actionsts))
310306
or bound to UI-Components in the UI-Layer for reactivity.
311307
```ts title="todo.controller.ts in 📁todo"
312-
import {App} from '../../app';
308+
import {createCollection, createComputed} from "@agile-ts/core";
313309
import {TodoInterface} from './todo.interfaces';
314310
import {CURRENT_USER} from '../user'
315311

316312
// Contains all existing TODO's
317-
export const TODOS = App.createCollection<TodoInterface>()();
313+
export const TODOS = createCollection<TodoInterface>()();
318314

319315
// Contains all TODO's that belong to the current logged in USER
320-
export const USER_TODOS = App.createComputed(() => {
316+
export const USER_TODOS = createComputed(() => {
321317
return TodosCollection.getGroup(CURRENT_USER.value.id).output;
322318
});
323319
```

docs/packages/core/Introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ which includes, for example, handy classes like:
4444
that we need to remember globally at a later point in time.
4545
While offering a toolkit to use and mutate this _set_ of Information.
4646
```ts
47-
const MY_COLLECTION = App.createCollection();
47+
const MY_COLLECTION = createCollection();
4848

4949
// Add Data to Collection
5050
MY_COLLECTION.collect({id: 1, name: "frank"});
@@ -57,7 +57,7 @@ which includes, for example, handy classes like:
5757
A `Computed` is an extension of the `State Class` that computes
5858
its value from a specified function.
5959
```ts
60-
const MY_COMPUTED = App.createComputed(() => {
60+
const MY_COMPUTED = createComputed(() => {
6161
return MY_STATE_1.value + MY_STATE_2.value;
6262
});
6363
```

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ created with an instantiated `Agile Instance` called `App`:
1919

2020
- [State](../state/Introduction.md)
2121
```ts
22-
const MY_STATE = new State(App, "Hello there");
22+
const MY_STATE = new State(sharedAgileInstance, "Hello there");
2323
// equals to
24-
const MY_STATE = App.createState("Hello there");
24+
const MY_STATE = createState("Hello there");
2525
```
2626
- [Collection](../collection/Introduction.md)
2727
```ts
28-
const MY_COLLECTION = new Collection(App);
28+
const MY_COLLECTION = new Collection(sharedAgileInstance);
2929
// equals to
30-
const MY_COLLECTION = App.createCollection();
30+
const MY_COLLECTION = createCollection();
3131
```
3232
- [Computed](../computed/Introduction.md)
3333
```ts
34-
const MY_COMPUTED = new Computed(App, () => 'hello');
34+
const MY_COMPUTED = new Computed(sharedAgileInstance, () => 'hello');
3535
// equals to
36-
const MY_COMPUTED = App.createComputed(() => 'hello');
36+
const MY_COMPUTED = createComputed(() => 'hello');
3737
```
3838

3939
In summary the main tasks of the `Agile Class` are to:

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ createState('jeff', App);
3232
Creates a new [State](../state/Introduction.md),
3333
which is automatically bound to the [Agile Instance](../agile-instance/Introduction.md) it was created from.
3434
```ts
35-
const State = App.createState('jeff', {
35+
const State = createState('jeff', {
3636
key: 'dummyState',
3737
})
3838
```
@@ -80,14 +80,14 @@ createCollection({}, App);
8080
Creates a new [Collection](../collection/Introduction.md),
8181
which is automatically bound to the [Agile Instance](../agile-instance/Introduction.md) it was created from.
8282
```ts {1-4,8-13}
83-
const Collection = App.createCollection({
83+
const Collection = createCollection({
8484
key: 'dummyCollection',
8585
groups: ['myGroup']
8686
})
8787

8888
// or
8989

90-
const Collection2 = App.createCollection((collection) => ({
90+
const Collection2 = createCollection((collection) => ({
9191
key: 'dummyCollection',
9292
groups: {
9393
myGroup: collection.Group(['item1', 'item2'])
@@ -138,11 +138,11 @@ createComputed(() => {}, {agileInstance: App});
138138
Creates a new [Computed](../computed/Introduction.md),
139139
which is automatically bound to the [Agile Instance](../agile-instance/Introduction.md) it was created from.
140140
```ts {1,5-7}
141-
const Computed = App.createComputed(() => {/* Computed Method */}, [/* hard coded deps */])
141+
const Computed = createComputed(() => {/* Computed Method */}, [/* hard coded deps */])
142142

143143
// or
144144

145-
const ComputedWithConfig = App.createComputed(() => {/* Computed Method */}, {
145+
const ComputedWithConfig = createComputed(() => {/* Computed Method */}, {
146146
key: 'dummyComputed',
147147
}, [/* hard coded deps */])
148148
```
@@ -245,7 +245,7 @@ createStorage({/* config */});
245245
Creates a new [Storage](../storage/Introduction.md) Interface for AgileTs.
246246
Such Storage Interface allows AgileTs to easily work with the Storage the Interface represents hand in hand.
247247
```ts
248-
const Storage = App.createStorage({
248+
const Storage = createStorage({
249249
key: 'dummyStorage',
250250
methods: {
251251
get: (key: string) => {},
@@ -288,7 +288,7 @@ The [Local Storage](https://developer.mozilla.org/de/docs/Web/API/Window/localSt
288288
Below you can see how the Local Storage is registered internally, if the `localStorage` flag got set.
289289
```ts {13}
290290
// create localStorage Interface with help of the Agile Storage
291-
const _localStorage = App.createStorage({
291+
const _localStorage = createStorage({
292292
key: 'localStorage',
293293
async: false,
294294
methods: {

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ MY_COLLECTION.collect({id: 1, name: "jeff"}).persist().removeGroup('myGroup').re
5151
### 🔨 Use case
5252
We might use a Collection to remember a flexible and reactive array of todo objects.
5353
```ts
54-
const TODOS = App.createCollection();
54+
const TODOS = createCollection();
5555
// <- add todos
5656
TODOS.collect({id: 1, todo: "Clean bathroom"}, ["user1"]);
5757
TODOS.collect({id: 2, todo: "Write Agile docs"}, ["user1"]);
@@ -173,8 +173,6 @@ console.log(MY_SELECTOR.value); // Returns '{id: 'id0', name: 'jeff'}'
173173

174174
```ts
175175
new Collection(agileInstance, config);
176-
// or
177-
App.createCollection(config);
178176
// or
179177
createCollection(config);
180178
```
@@ -189,7 +187,7 @@ There are two different ways of configuring a Collection. Both have their advant
189187
But on the other hand, it gives us some limitations, since we aren't creating and configuring the Groups and Selectors on our own.
190188
The Collection takes care of it instead.
191189
```ts
192-
App.createCollection({
190+
createCollection({
193191
key: 'dummyCollection',
194192
group: ["dummyGroup"]
195193
})
@@ -199,7 +197,7 @@ There are two different ways of configuring a Collection. Both have their advant
199197
This gives us more freedom in configuring Instances like Groups,
200198
because we have access to the Collection and can create them on our own.
201199
```ts
202-
App.createCollection((collection) => ({
200+
createCollection((collection) => ({
203201
key: 'dummyCollection',
204202
group: {
205203
dummyGroup: collection.Group(["item1", "item2"])
@@ -228,15 +226,15 @@ There are two different ways of doing so.
228226
The first one is to pass an Array of Group keys/names,
229227
where AgileTs takes care of the Group's creation and names them according to the passed keys.
230228
```ts
231-
App.createCollection({
229+
createCollection({
232230
groups: ["myGroup1", "myGroup2"]
233231
});
234232
```
235233
The way mentioned above has some limitations, since we can't configure the Groups ourselves.
236234
Fortunately, there is a second way where we have access to the Collection itself,
237235
and can define and configure the Groups on our own.
238236
```ts
239-
App.createCollection((collection) => ({
237+
createCollection((collection) => ({
240238
key: 'dummyCollection',
241239
group: {
242240
myGroup1: collection.Group(["item1", "item2"], {/* some configuration */}),
@@ -257,15 +255,15 @@ As with the `groups` property, there are two different ways of doing so.
257255
The first one is to pass an Array of Selector keys/names,
258256
where AgileTs takes care of the Selector's creation and names them according to the passed keys.
259257
```ts
260-
App.createCollection({
258+
createCollection({
261259
selectors: ["mySelector1", "mySelector2"]
262260
});
263261
```
264262
The way mentioned above has some limitations, since we can't configure the Selectors ourselves.
265263
Fortunately, there is a second way where we have access to the Collection itself,
266264
and can define and configure the Selectors on our own.
267265
```ts
268-
App.createCollection((collection) => ({
266+
createCollection((collection) => ({
269267
key: 'dummyCollection',
270268
selectors: {
271269
mySelector1: collection.Selector("item1", {/* some configuration */}),
@@ -283,7 +281,7 @@ App.createCollection((collection) => ({
283281
#### `key`
284282
The optional property `key/name` should be a unique `string/number` to identify the Collection later.
285283
```ts
286-
App.createCollection({
284+
createCollection({
287285
key: "myKey"
288286
});
289287
```
@@ -302,7 +300,7 @@ We recommend giving each Collection a unique `key`, since it has only advantages
302300
Defines which property's value in collected data is selected as `primaryKey`.
303301
By default, it is `id`. A `primaryKey` identifies a specific Item and has to be part of each collected data.
304302
```ts
305-
const MY_COLLECTION = App.createCollection({
303+
const MY_COLLECTION = createCollection({
306304
primaryKey: "key"
307305
});
308306
MY_COLLECTION.collect({key: 1, name: "hans"});
@@ -321,7 +319,7 @@ MY_COLLECTION.collect({key: 1, name: "hans"});
321319
Describes the `key/name` of the default [Group](#-groupgroupintroductionmd).
322320
By default, it is `default`.
323321
```ts
324-
App.createCollection({
322+
createCollection({
325323
defaultGroupKey: "allItemsOfCollectionKey"
326324
});
327325
```
@@ -336,7 +334,7 @@ The default Group represents all Items of the Collection.
336334
#### `initialData`
337335
Here we can set the initial Data of our Collection.
338336
```ts
339-
App.createCollection({
337+
createCollection({
340338
initialData: [{id: 1, name: "hans"}, {id: 2, name: "frank"}]
341339
});
342340
```
@@ -356,7 +354,7 @@ interface UserInterface {
356354
name: string
357355
}
358356

359-
const MY_COLLECTION = App.createState<UserInterface>();
357+
const MY_COLLECTION = createState<UserInterface>();
360358
MY_COLLECTION.collect({id: "invalidType", animal: "Lion"}); // type Error
361359
MY_COLLECTION.collect({id: 1, name: "hans"}); // Success
362360
```

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Creates a new [Group](./group/Introduction.md) without associating it to the Col
5353
Therefore, this function is intended for use in the Collection `config` object,
5454
where the `constructor()` takes care of the associating.
5555
```ts {3}
56-
App.createCollection((collection) => ({
56+
createCollection((collection) => ({
5757
groups: {
5858
myGroup: collection.Group(["item1", "item2"])
5959
}
@@ -65,13 +65,13 @@ collection.Group(["item1", "item2"]);
6565
```
6666
The object key is used as `groupKey`, if we don't pass a separate key into the Group `config`.
6767
```ts {3,9}
68-
App.createCollection((collection) => ({
68+
createCollection((collection) => ({
6969
groups: {
7070
myGroup: collection.Group(["item1", "item2"], {key: "myCoolGroup"}) // Key === "myCoolGroup"
7171
}
7272
}));
7373

74-
App.createCollection((collection) => ({
74+
createCollection((collection) => ({
7575
groups: {
7676
myGroup: collection.Group(["item1", "item2"]) // Key === "myGroup"
7777
}
@@ -112,7 +112,7 @@ Creates a new [Selector](./selector/Introduction.md) without associating it to t
112112
Therefore, this function is intended for use in the Collection `config` object,
113113
where the `constructor()` takes care of the associating.
114114
```ts {3}
115-
App.createCollection((collection) => ({
115+
createCollection((collection) => ({
116116
selectors: {
117117
mySelector: collection.Selector("item1")
118118
}
@@ -124,13 +124,13 @@ collection.Selector("item1");
124124
```
125125
The object key is used as `selectorKey`, if we don't pass a separate key into the Selector `config`.
126126
```ts {3,9}
127-
App.createCollection((collection) => ({
127+
createCollection((collection) => ({
128128
selectors: {
129129
mySelector: collection.Selector("item1", {key: "myCoolSelector"}) // Key === "myCoolSelector"
130130
}
131131
}));
132132

133-
App.createCollection((collection) => ({
133+
createCollection((collection) => ({
134134
selectors: {
135135
mySelector: collection.Selector("item1") // Key === "mySelector"
136136
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Agile
4141
The current `key/name` of the Collection,
4242
which is used for a unique identification.
4343
```ts {2}
44-
const MY_COLLECTION = App.createCollection({key: 'jeffKey'});
44+
const MY_COLLECTION = createCollection({key: 'jeffKey'});
4545
MY_COLLECTION.key; // Returns 'jeffKey'
4646
```
4747
Besides accessing the `key`, we can also assign a new `key` using this property.
@@ -220,4 +220,4 @@ MY_COLLECTION.selectors[1]; // Bad pattern
220220

221221
```ts
222222
{ [key: string]: Selector<DataType> }
223-
```
223+
```

0 commit comments

Comments
 (0)