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

Commit 0481e93

Browse files
authored
Merge pull request #20 from agile-ts/develop
Develop
2 parents 977f5e6 + 5919c64 commit 0481e93

File tree

8 files changed

+309
-107
lines changed

8 files changed

+309
-107
lines changed

docs/packages/core/Introduction.md

+48-26
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,59 @@ slug: /core
2121

2222
## `core`
2323

24-
The `core` package is the brain of AgileTs and handles nearly everything related to AgileTs.
25-
- Manages your Agile Sub Instances ([State](./features/state/Introduction.md), ..)
26-
- Ingest changes into the Runtime
27-
- Triggers rerender on Integrations like [React](../react/Introduction.md)
28-
29-
Each mentioned feature is related to the [`Agile Class`](./features/agile-instance/Introduction.md) which
30-
is located in the `core`
24+
The `core` package is the brain of AgileTs.
25+
Nearly everything that is related to AgileTs depends on this package.
26+
The main reason for this is that it includes the main Instance of AgileTs,
27+
the `Agile Class` here called `App`.
3128
```ts
3229
const App = new Agile();
3330
```
34-
Agile Sub Instance like
31+
In summary, the main tasks of the `Agile Class` are to
32+
- manage and store our Agile Sub Instances ([State](./features/state/Introduction.md), ..)
33+
- ingest changes into the Runtime
34+
- trigger rerender on Integrations like [React](../react/Introduction.md)
35+
36+
As you can guess each application uses AgileTs has to install
37+
the `core` package and instantiate such an `Agile Class`.
38+
To get some inspiration where to instantiate our `Agile Class`, checkout the [style guide](../../main/StyleGuide.md).
39+
Beside the `Agile Class` the `core` holds some other useful classes which are
40+
listed below. But each of these classes depends in some kind on the `Agile Class`.
41+
42+
### ⚡️ [State](./features/state/Introduction.md)
43+
A State holds an Information that we need to remember at a later point in time.
44+
```ts
45+
const MY_STATE = App.createState("Hello there");
46+
MY_STATE.set("hi"); // Mutate State Value
47+
MY_STATE.undo(); // Undo latest change
48+
```
49+
50+
### 👨‍👧‍👦 [Collection](./features/collection/Introduction.md)
51+
A Collection holds a set of Information that we need to remember at a later point in time.
52+
It is designed for arrays of data objects following the same pattern.
53+
```ts
54+
const MY_COLLECTION = App.createCollection();
55+
MY_COLLECTION.collect({id: 1, name: "frank"}); // Add Data to Collection
56+
MY_COLLECTION.remove(1).everywhere(); // Remove Data at primary Key '1' from Collection
57+
```
58+
59+
### 🤖 [Computed](./features/state/Introduction.md)
60+
A Computed is an extension of the State Class, it does auto compute its value depending on other Instances.
61+
```ts
62+
const MY_COMPUTED = App.createComputed(() => (MY_STATE_1.value + MY_STATE_2.value));
63+
```
64+
65+
### 🚌 [Event](./features/event/Introduction.md)
66+
```ts
67+
const MY_EVENT = App.createEvent();
68+
MY_EVENT.on(() => {console.log("hello there")}); // Print 'hello there' if Event gets triggered
69+
MY_EVENT.trigger(); // Trigger Event
70+
```
3571

72+
## 🚀 Quick Links
3673
- [State](./features/state/Introduction.md)
37-
```ts
38-
const MY_STATE = App.createState("Hello there");
39-
```
4074
- [Collection](./features/collection/Introduction.md)
41-
```ts
42-
const MY_COLLECTION = App.createCollection();
43-
```
4475
- [Computed](./features/computed/Introduction.md)
45-
```ts
46-
const MY_COMPUTED = App.createComputed(() => {});
47-
```
4876
- [Event](./features/event/Introduction.md)
49-
```ts
50-
const MY_EVENT = App.createEvent();
51-
```
52-
53-
has it originates from the `Agile Class`.
54-
Each Application using AgileTs must instantiate such an Agile Instance.
55-
It doesn't matter where we instantiate our main Agile Instance,
56-
but be aware that it isn't recommend having multiple Agile Instances in one single Application.
57-
You might check out the [style guides](../../main/StyleGuide.md) to get some inspiration how to structure an Application having AgileTs as state manager.
77+
- [Group](./features/collection/group/Introduction.md)
78+
- [Selector](./features/collection/selector/Introduction.md)
79+
- [Storage](./features/storage/Introduction.md)

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

+28-22
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ WIP docs!
1111

1212
:::
1313

14-
The _Agile Instance_ is created with `new Agile()`and should be unique to our application.
14+
The `Agile Class` is the foundation of AgileTs,
15+
nearly everything related to AgileTs depends in some kind on it.
1516
```ts
1617
const App = new Agile();
1718
```
18-
With an instantiated _Agile Instance_, we are able to create any Agile Sub Instances like
19+
Each created Agile Instance should be unique to our application,
20+
and we should avoid having multiple from these in one application.
21+
The Agile Instance can be seen as the store, which offers many powerful features
22+
to mutate and work with the stored Instances.
23+
Such Instances can be created with help of the Agile Instance and get automatically stored in it.
1924
- [State](../state/Introduction.md)
2025
```ts
2126
const MY_STATE = App.createState("Hello there");
@@ -33,10 +38,6 @@ With an instantiated _Agile Instance_, we are able to create any Agile Sub Insta
3338
const MY_EVENT = App.createEvent();
3439
```
3540

36-
These Sub Instances created with the help of the `Agile Class` are automatically bound to it.
37-
Because of the storing behaviour, the `Agile Class` can also be seen as a Store,
38-
that offers many features to mutate and work with the stored Instances.
39-
4041
## 📭 Props
4142

4243
`Agile` takes an optional configuration object as its only parameter.
@@ -60,9 +61,11 @@ export interface CreateAgileConfigInterface {
6061

6162
### `logConfig`
6263

63-
The logConfig is thought to configure the Logger of AgileTs.
64-
For instance, we can configure if we want to log all messages or
65-
only warnings. [Here](../../../../Interfaces.md#createloggerconfig) you can find all configuration options.
64+
The `logConfig` is thought to configure the Logger of AgileTs.
65+
The Agile Logger simply logs important events in the console, like warnings or errors,
66+
but it also logs runtime events if this is desired.
67+
So for instance here we can configure if we want to log all messages or
68+
only warnings.
6669
```ts
6770
const App = new Agile({
6871
logConfig: {
@@ -71,25 +74,29 @@ const App = new Agile({
7174
},
7275
});
7376
```
77+
To find out more about possible configuration options, checkout the [CreateLoggerConfigInterface](../../../../Interfaces.md#createloggerconfig).
7478

7579

7680
### `localStorage`
7781

78-
Defines whether we want to use the Local Storage as default Storage or not.
79-
If we use the Local Storage each Agile Sub Instance we persist, gets stored in the Local Storage by default.
80-
We aren't limited to the Local Storage, we can configure our own [Storage](../storage/Introduction.md).
81-
This is in a Mobile Environment necessary, because there the Local Storage doesn't exist.
82-
With `App.registerStorage()` we can register our wished [Storage](../storage/Introduction.md).
82+
Defines whether AgileTs creates an interface to the `localStorage` for us.
83+
If we have decided to use the local storage, each Agile Sub Instance we
84+
persist, gets stored into the `localStorage` by default.
8385
```ts
8486
const App = new Agile({
8587
localStorage: false // default true
8688
});
8789
```
90+
Of course, we aren't limited to the `localStorage`.
91+
We are able to create an Interface to any [Storage](../storage/Introduction.md) we want.
92+
For instance is this necessary in the Mobile Environment, because there
93+
the `localStorage` doesn't exists. With `App.registerStorage()` we can register our own [Storage](../storage/Introduction.md).
8894

8995
### `waitForMount`
9096

91-
With `waitForMount` we define if AgileTs should wait
92-
with causing rerender on an unmounted Component until it got mounted.
97+
With this flag we can determine
98+
whether AgileTs should wait until unmounted
99+
components are mounted before rerendering them.
93100
```ts
94101
const App = new Agile({
95102
waitForMount: false // default true
@@ -99,12 +106,11 @@ const App = new Agile({
99106

100107
## 🟦 Typescript
101108

102-
`Agile Class` is almost 100% typesafe.
109+
The `Agile Class` is almost 100% typesafe.
103110

104111
## 🗺 Where to instantiate?
105112

106-
You can instantiate the Agile Instance where ever you want.
107-
Directly in your Component, in an extra File or on Paper.
108-
It doesn't matter as long as you can work with it.
109-
There are a few [Style Guides](../../../../main/StyleGuide.md) where you can get some inspiration
110-
how to structure an Application using AgileTs.
113+
We can instantiate the Agile Instance of our application where ever we want.
114+
Directly in our Component, in a separate file or on paper.
115+
It doesn't matter as long as we can work with it.
116+
There are a few [Style Guides](../../../../main/StyleGuide.md) which might help us with such hard decision.

0 commit comments

Comments
 (0)