32
32
.
33
33
```
34
34
We use the ` core ` of a simple TODO application to visually illustrate how such a ` core ` can be constructed.
35
- Our todo application has two main [ Entities] ( #📁-entities ) , that AgileTs can handle.
35
+ Our todo application has two main [ Entities] ( #📁-entities ) , that AgileTs should handle.
36
36
The ** User** and of course, the ** TODO-Item** . These two parts are mapped in our ` core ` .
37
37
``` js title="TodoList-Core"
38
38
core
@@ -88,7 +88,7 @@ Our `core` consists of several entities, which exist apart from each other, havi
88
88
Each ` Entity ` manages its Data separately by doing rest calls or mutating States. This separation makes our ` core ` more
89
89
structured, readable and improves maintainability.
90
90
91
- ** For instance :** <br />
91
+ ** For example :** <br />
92
92
The _ User Entity_ should only treat the user's whole logic and shouldn't do rest calls, for instance, for the _ Todo Entity_ .
93
93
94
94
### 📝 index.ts
@@ -111,13 +111,15 @@ export default {
111
111
112
112
### 📝 .action.ts
113
113
114
- An action does handle the logic of our Entity. We should name the actions after action names like ` createX ` , ` removeY ` .
115
- In general, an action modifies the ` State ` , makes rest calls through the functions provided by the [ route.ts] ( #-routets ) file
116
- , and computes some values if necessary.
114
+ Here all actions of the Entity are listed .
115
+ In general, an action modifies the ` State ` , makes rest calls ( through the functions provided by the [ route.ts] ( #-routets ) file),
116
+ and computes some values if necessary.
117
117
In principle, actions always happen in response to an event. For example, if the add todo button got clicked.
118
+ Therefore, they should be called after action sounding names. For instance ` createTodo ` , ` removeTodo ` .
118
119
119
- ** For instance:** <br />
120
- The creation of a Todo-Item in the UI-Layer triggers the ` addTodo() ` action, which then mutates our State and makes rest calls.
120
+ ** For example:** <br />
121
+ The creation of a Todo-Item in the UI-Layer triggers the ` addTodo() ` action,
122
+ which then mutates our TodoItems State and makes a rest call to add the todo to our backend.
121
123
122
124
``` ts title="todo.action.ts in 📁todo"
123
125
import {TodoInterface } from ' ./todo.interface' ;
@@ -138,8 +140,8 @@ export const addTodo = async (userId: string, description: string): Promise<void
138
140
139
141
### 📝 .controller.ts
140
142
141
- The Controller manages and represents the Agile Sub Instance like States, Collections, .. for the Entity.
142
- These Agile Sub Instances might get modified by the [ action.ts] ( #📝-.action.ts ) or bound to a Component in the UI-Layer.
143
+ The ` controller.ts ` manages and represents the Agile Sub Instance ( like States, Collections, ..) for an Entity.
144
+ These Agile Sub Instances might get modified by the actions in the [ action.ts] ( #📝-.action.ts ) or bound to a Component in the UI-Layer.
143
145
``` ts title="todo.controller.ts in 📁todo"
144
146
import {App } from ' ../../app' ;
145
147
import {TodoInterface } from ' ./todo.interface' ;
@@ -165,7 +167,7 @@ The `interface` section can be ignored by non [Typescript](https://www.typescrip
165
167
If you are a [ Typescript] ( https://www.typescriptlang.org/ ) user, you properly want to create some interfaces for your Entity.
166
168
These interfaces belonging to this Entity should be defined here.
167
169
168
- ** For instance ** <br />
170
+ ** For example ** <br />
169
171
In case of the TODO-Entity, it contains the ` TodoInterface ` .
170
172
171
173
``` ts title="todo.interface.ts in 📁todo"
@@ -181,7 +183,7 @@ export interface TodoInterface {
181
183
182
184
In order to communicate to our server, we have to create [ rest calls] ( https://en.wikipedia.org/wiki/Representational_state_transfer ) .
183
185
For better maintainability, these rest calls are outsourced from the [ action.ts] ( #-actionts ) and provided by this section in function shape.
184
- The routes should only be used in the [ action.ts] ( #-actionts ) of the Entity.
186
+ These route functions should only be used in the [ action.ts] ( #-actionts ) of the Entity.
185
187
It's not recommended calling them from outside the corresponding Entity.
186
188
``` ts title="todo.route.ts in 📁todo"
187
189
import {TodoInterface } from " ./todo.interface" ;
@@ -205,7 +207,7 @@ export const ADD_TODO = async (payload: AddTodoPayloadInterface): Promise<TodoIn
205
207
In the ` app ` file, we create our main ` Agile Instance ` and configure it to meet our needs.
206
208
For example, we determine here with which UI framework AgileTs should work together.
207
209
States, Collections, etc. can then be created with the help of this instance.
208
- ** It's not recommended to have multiple ` Agile Instances ` in one application!!**
210
+ ** It's not recommended having multiple ` Agile Instances ` in one application!!**
209
211
210
212
``` ts title="app.ts"
211
213
import {Agile } from " @agile-ts/core" ;
@@ -216,8 +218,8 @@ export const App = new Agile({logJobs: true}).use(reactIntegration);
216
218
217
219
## 📝 index.ts
218
220
219
- Here we export our ` core ` entities so that each entity can be reached without any detours.
220
- In our UI-Layer we than simply import our ` core ` and can mutate entities like the Todo-Entity (` core.todo.addTodo(/* */) ` )
221
+ Here we export our ` core ` Entities so that each Entity can be reached without any detours.
222
+ In our UI-Layer we than simply import our ` core ` and can mutate Entities like the Todo-Entity (` core.todo.addTodo(/* */) ` )
221
223
without further thinking.
222
224
``` ts title="index.ts"
223
225
import todo from " ./controllers/todo" ;
0 commit comments