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

Commit 3ce0a3d

Browse files
committed
fixed typos
1 parent 3ea3073 commit 3ce0a3d

File tree

4 files changed

+56
-94
lines changed

4 files changed

+56
-94
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Want to learn more about the Computed State's specific methods?
6969
Check out the [Computed Methods](./Methods.md) documentation.
7070
Most methods we use to modify, mutate and access the Computed are chainable.
7171
```ts
72-
MY_COMPUTED.undo().recompute().watch(() => {}).undo();
72+
MY_COMPUTED.recompute().ingest();
7373
```
7474

7575
## 🔨 Use case

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

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,59 @@ Test the State yourself. It's only one click away. Just select your preferred Fr
7272
- Angular (coming soon)
7373

7474

75-
## 📭 Props
75+
## 👟 Light State
7676

77+
The `Light State` is a lightweight alternative to the `Enhanced State`,
78+
which is referred as the 'normal' State in this documentation.
79+
It is the State in its rawest and lightest form.
80+
Thus, it is recommended when no additional functionalities
81+
like `persist()`, `watch()`, `undo()`, .. are required.
7782
```ts
7883
new State(agileInstance, initialValue, config);
7984
// or
85+
createLightState(initialValue, config);
86+
```
87+
#### Methods contained in the `Light State`
88+
- `setKey()`
89+
- `set()`
90+
- `ingest()`
91+
- `addSideEffect()`
92+
- `removeSideEffect()`
93+
- `hasSideEffect()`
94+
95+
96+
## 🏋️ Enhanced State
97+
98+
What we refer as a 'normal' State in this documentation is the `Enhanced State`.
99+
Actually the `Enhanced State` is an extension of the `Light State` (normal State)
100+
with many additional features.
101+
Since the `Enhanced State` is the most commonly used type of State,
102+
the `createState()` method creates an `Enhanced State`.
103+
```ts
104+
new EnhancedState(agileInstance, initialValue, config);
105+
// or
80106
createState(initialValue, config);
107+
// or
108+
createEnhancedState(initialValue, config);
109+
```
110+
However, since the `Enhanced State` is bloated with features,
111+
it requires a larger bundle size than the `Light State`.
112+
113+
114+
## 📭 Props
115+
116+
```ts
117+
// Enhanced State
118+
new EnhancedState(agileInstance, initialValue, config);
119+
// or
120+
createState(initialValue, config);
121+
// or
122+
createEnhancedState(initialValue, config);
123+
124+
// Light State
125+
new State(agileInstance, initialValue, config);
126+
// or
127+
createLightState(initialValue, config);
81128
```
82129

83130
### `initialValue`
@@ -187,8 +234,3 @@ const MY_STATE = createState<string>("Hello World");
187234
MY_STATE.set(1); // Error
188235
MY_STATE.set("hello space"); // Success
189236
```
190-
Javascript users can also get rudimentary type safety with the `type()` method.
191-
```ts
192-
MY_STATE.type(String); // Now State only accept State Values
193-
```
194-
Be aware that the `type()` method currently only supports primitive types and does its type check at `runtime`.

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

Lines changed: 6 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Returns the [State](./Introduction.md) it was called on.
147147

148148
## `type()`
149149

150-
::: warning
150+
:::warning
151151

152152
The `type()` method has been deprecated in the latest version `^0.2.0`
153153
and is no longer available!
@@ -156,47 +156,10 @@ and is no longer available!
156156
Reducing `core` package size.
157157

158158
### Alternative?
159-
No. Please open an issue in github if needed, so we can reconsider this decision.
160-
161-
:::
162-
163-
:::info
164-
165-
If you are working with [Typescript](https://www.typescriptlang.org/),
166-
we strongly recommend using generic types instead of the `type()` method!
167-
```ts
168-
const MY_STATE = createState<string>("hi");
169-
MY_STATE.set(1); // type Erro
170-
MY_STATE.set("bye"); // Success
171-
```
159+
No. Consider using [`Typescript`](https://www.typescriptlang.org/) if you want a proper typesafety.
172160

173161
:::
174162

175-
Through the `type()` method, we can get a rudimentary type safety in Javascript.
176-
It enforces the State to only accept values fitting to the before-defined primitive `type` at runtime.
177-
```ts {1}
178-
MY_STATE.type(String);
179-
MY_STATE.set(1); // Error at runtime
180-
MY_STATE.set("hi"); // Success at runtime
181-
```
182-
The `type()` method takes in the JS constructor for that type. Possible options are:
183-
```
184-
Boolean, String, Object, Array, Number
185-
```
186-
187-
### 📭 Props
188-
189-
| Prop | Type | Default | Required |
190-
|----------------|------------------------------|--------------|----------|
191-
| `type` | any | undefined | No |
192-
193-
### 📄 Return
194-
195-
```ts
196-
State
197-
```
198-
Returns the [State](./Introduction.md) it was called on.
199-
200163

201164

202165
<br />
@@ -209,7 +172,7 @@ Returns the [State](./Introduction.md) it was called on.
209172

210173
## `hasCorrectType()`
211174

212-
::: warning
175+
:::warning
213176

214177
The `hasCorrectType()` method has been deprecated in the latest version `^0.2.0`
215178
and is no longer available!
@@ -218,30 +181,10 @@ and is no longer available!
218181
Reducing `core` package size.
219182

220183
### Alternative?
221-
No. Please open an issue in github if needed, so we can reconsider this decision.
184+
No. Consider using [`Typescript`](https://www.typescriptlang.org/) if you want a proper typesafety.
222185

223186
:::
224187

225-
Compares the given value type with the type defined in the [`type()`](#type) method.
226-
```ts {2,3}
227-
MY_STATE.type(String);
228-
MY_STATE.hasCorrectType("hi"); // Returns 'true'
229-
MY_STATE.hasCorrectType(12); // Returns 'false'
230-
```
231-
If we haven't defined any specific type using the `type()` method, `true` is returned.
232-
233-
### 📭 Props
234-
235-
| Prop | Type | Default | Required |
236-
|----------------|-------------------------------------------------------------------------------------|------------|----------|
237-
| `value` | any | undefined | Yes |
238-
239-
### 📄 Return
240-
241-
```ts
242-
boolean
243-
```
244-
245188

246189

247190
<br />
@@ -489,7 +432,7 @@ Returns the [State](./Introduction.md) it was called on.
489432

490433
## `hasWatcher()`
491434

492-
::: warning
435+
:::warning
493436

494437
The `hasWatcher()` method has been deprecated in the latest version `^0.2.0`
495438
and is no longer available!
@@ -499,32 +442,11 @@ Reducing `core` package size.
499442

500443
### Alternative?
501444
```ts
502-
hasSideEffect('watcherKey');
445+
MY_STATE.hasSideEffect('watcherKey');
503446
```
504447

505448
:::
506449

507-
Checks if a [watcher callback](#watch) exists at the given `watcherKey` in the State.
508-
```ts {4,5}
509-
MY_STATE.watch("myKey", (value) => {
510-
// do something
511-
});
512-
MY_STATE.hasWatcher("myKey"); // Returns 'true'
513-
MY_STATE.hasWatcher("unknownKey"); // Returns 'false'
514-
```
515-
516-
### 📭 Props
517-
518-
| Prop | Type | Default | Required |
519-
|----------------|---------------------------------------------------------------------------|------------|----------|
520-
| `watcherKey` | number \| string | undefined | Yes |
521-
522-
### 📄 Return
523-
524-
```ts
525-
boolean
526-
```
527-
528450

529451

530452
<br />

src/core/entities/ui/ui.controller.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
import { createState } from '@agile-ts/core';
22

3-
export const ASTRONAUT_DARK = createState<boolean>(false).persist(
4-
'astronaut_color'
5-
);
3+
export const ASTRONAUT_DARK = createState<boolean>(false);

0 commit comments

Comments
 (0)