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

Commit 85a6feb

Browse files
authored
Merge pull request #94 from agile-ts/develop
Updated Algolia Config
2 parents 2ac04cc + bc0bd9a commit 85a6feb

File tree

30 files changed

+3534
-2045
lines changed

30 files changed

+3534
-2045
lines changed

docs/Interfaces.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,11 @@ Here is a Typescript Interface for quick reference. However,
303303
each property is explained in more detail below.
304304
```ts
305305
export interface StatePersistentConfigInterface {
306+
key?: string | number;
306307
loadValue?: boolean;
307308
storageKeys?: StorageKey[];
309+
onMigrate?: (value: any) => ValueType;
310+
onSave?: (value: ValueType) => any;
308311
}
309312
```
310313

@@ -317,12 +320,12 @@ Or, if the State isn't persisted yet, it stores the State value in the correspon
317320
Be aware that if we don't allow the `Persistent` to load/store the value, we have to do it ourselves.
318321
```ts {2}
319322
myState.persist({
320-
instantiate: false,
323+
loadValue: false,
321324
});
322325

323326
if (myState.persistent?.ready) {
324327
await myState.persistent?.initialLoading();
325-
myState.isPersisted = true;
328+
myState.isPersisted = true;
326329
}
327330
```
328331
Loading the value manually has one advantage.

docs/main/Contributing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
id: contributing
3-
title: Contributing
4-
sidebar_label: Contributing to AgileTs
3+
title: Contributing to AgileTs
4+
sidebar_label: Contributing
55
slug: /contributing
66
description: Contributions to AgileTs are not hard and very welcome.
77
image: img/meta.png

docs/main/Introduction.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
id: introduction
33
title: Introducing AgileTs
44
sidebar_label: Introduction
5-
slug: /introduction/
6-
description: A global State and Logic Library implemented in Typescript, offering a reimagined API that focuses on developer experience. The AgileTs state management functionality can be used in various frameworks like React, Vue and plain Javascript.
5+
slug: /introduction
6+
description: An atom based global State and Logic Library implemented in Typescript, offering a reimagined API that focuses on developer experience. The AgileTs state management functionality can be used in various frameworks like React, Vue and plain Javascript.
77
image: img/meta.png
88
---
99

1010
## 👋 Introduction {#introduction}
1111

12-
AgileTs is a global State and Logic Library implemented in Typescript.
12+
AgileTs is an atom based global State and Logic Library implemented in Typescript.
1313
It offers a reimagined API that focuses on **developer experience**
1414
and allows you to **easily** and **flexible** manage your application States.
1515
Besides [States](../packages/core/api/state/Introduction.md),
16-
AgileTs offers some other powerful and tree shakable APIs that make your life easier,
16+
AgileTs offers some other powerful APIs that make your life easier,
1717
such as [Collections](../packages/core/api/collection/Introduction.md)
1818
and [Computed States](../packages/core/api/computed/Introduction.md).
1919
The philosophy behind AgileTs is simple:
@@ -35,7 +35,7 @@ MY_STATE.undo();
3535
MY_STATE.reset();
3636

3737
// Permanently store the State value in an external Storage
38-
MY_STATE.persist("storage-key");
38+
MY_STATE.persist({key: "storage-key"});
3939
```
4040

4141
### 🤸‍ Flexible {#flexible}

docs/main/StyleGuides.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,13 @@ and mutate its entities as wished without further thinking.
382382
For example when we want to add a Todo-Item to the TODO Collection
383383
we simply call `core.todo.addTodo(/* new todo */);`.
384384
```ts title="index.ts"
385-
import todo from "./controllers/todo";
386-
import user from "./controllers/user";
385+
import todo from "./entities/todo";
386+
import user from "./entities/user";
387387
import {globalBind} from "@agile-ts/core";
388388

389389
const core = {
390-
todo: todo,
391-
user: user,
390+
todo,
391+
user,
392392
};
393393

394394
// For better debugging we bind the core globally

docs/packages/api/Introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ slug: /api
1010
<a href="https://npm.im/@agile-ts/api">
1111
<img src="https://img.shields.io/npm/v/@agile-ts/api.svg?label=npm&style=flat&colorA=293140&colorB=4a4872" alt="npm version"/></a>
1212
<a href="https://npm.im/@agile-ts/api">
13-
<img src="https://img.shields.io/bundlephobia/min/@agile-ts/api.svg?label=minified%20size&style=flat&colorA=293140&colorB=4a4872" alt="npm minified size"/></a>
13+
<img src="https://img.shields.io/bundlephobia/minzip/@agile-ts/api.svg?label=minified%20size&style=flat&colorA=293140&colorB=4a4872" alt="npm minified size"/></a>
1414
<a href="https://npm.im/@agile-ts/api">
1515
<img src="https://img.shields.io/npm/dt/@agile-ts/api.svg?label=downloads&style=flat&colorA=293140&colorB=4a4872" alt="npm total downloads"/></a>
1616

docs/packages/core/Introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ slug: /core
1010
<a href="https://npm.im/@agile-ts/core">
1111
<img src="https://img.shields.io/npm/v/@agile-ts/core.svg?label=npm&style=flat&colorA=293140&colorB=4a4872" alt="npm version"/></a>
1212
<a href="https://npm.im/@agile-ts/core">
13-
<img src="https://img.shields.io/bundlephobia/min/@agile-ts/core.svg?label=minified%20size&style=flat&colorA=293140&colorB=4a4872" alt="npm minified size"/></a>
13+
<img src="https://img.shields.io/bundlephobia/minzip/@agile-ts/core.svg?label=minified%20size&style=flat&colorA=293140&colorB=4a4872" alt="npm minified size"/></a>
1414
<a href="https://npm.im/@agile-ts/core">
1515
<img src="https://img.shields.io/npm/dt/@agile-ts/core.svg?label=downloads&style=flat&colorA=293140&colorB=4a4872" alt="npm total downloads"/></a>
1616

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ Returns the [State](./Introduction.md) it was called on.
495495

496496
Preserves the State `value` in the appropriate local Storage for the current environment.
497497
```ts
498-
MY_STATE.perist("myStorageKey");
498+
MY_STATE.perist({key: "myStorageKey"});
499499
```
500500

501501
### 🤓 Learn more
@@ -507,7 +507,6 @@ checkout the [Persisting Data](../storage/PersistingData.md) Section.
507507

508508
| Prop | Type | Default | Description | Required |
509509
|----------------------|----------------------------------------------------------------------------|------------|---------------------------------------------------------------------------------------|----------|
510-
| `key` | string \| number | undefined | Key/Name of created Persistent (Note: Key is required if State has no set Key!) | No |
511510
| `config` | [StatePersistentConfig](../../../../Interfaces.md#statepersistentconfig) | {} | Configuration | No |
512511

513512
### 📄 Return

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ The prefix will be added before each `Storage Key`
202202
and is intended to highlight the items stored by AgileTs.
203203
A `Storage Key` identifies the stored value in the corresponding Storage.
204204
```ts
205-
MY_STATE.persist('myState');
205+
MY_STATE.persist({key: 'myState'});
206206
// Storage Key: '_prefix_myState'
207207
208-
MY_COLLECTION.persist('myCollection');
208+
MY_COLLECTION.persist({key: 'myCollection'});
209209
// Storage Keys:
210210
// Collection Indicator: '_prefix_myCollection'
211211
// Default Group: '_prefix__myCollection_group_default'

docs/packages/core/api/storage/PersistingData.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ slug: /core/persisting-data
88
It's common for applications to store data on the client browser.
99
AgileTs makes it pretty easy to achieve such goal.
1010
```ts
11-
MY_STATE.persist('storage-key-here');
11+
MY_STATE.persist({key: 'storage-key-here'});
1212
```
1313
Besides [States](../state/Introduction.md), we can persist nearly any [Agile Sub Instance](../../../../main/Introduction.md#agile-sub-instance).
1414
- [Collections](../collection/Introduction.md)
1515
```ts
16-
MY_COLLECTION.persist('storage-key-here');
16+
MY_COLLECTION.persist({key: 'storage-key-here'});
1717
```
1818
- [Selectors](../collection/selector/Introduction.md)
1919
```ts
20-
MY_SELECTOR.persist('storage-key-here');
20+
MY_SELECTOR.persist({key: 'storage-key-here'});
2121
```
2222
- [Groups](../collection/group/Introduction.md)
2323
```ts
24-
MY_GROUP.persist('storage-key-here');
24+
MY_GROUP.persist({key: 'storage-key-here'});
2525
```
2626

2727
Since many [Agile Sub Instance](../../../../main/Introduction.md#agile-sub-instance) can be persisted,
@@ -70,7 +70,7 @@ There are several ways to provide such required `storageKey` to the `persist()`
7070
```
7171
- **2.** Pass the `storageKey` directly into the `persist()` method.
7272
```ts {1}
73-
MY_INSTANCE.persist("myCoolPassedKey"); // Success (storageKey = 'myCoolPassedKey')
73+
MY_INSTANCE.persist({key: "myCoolPassedKey"}); // Success (storageKey = 'myCoolPassedKey')
7474
```
7575

7676
If AgileTs couldn't find any fitting `storageKey`,
@@ -103,3 +103,31 @@ By default, the AgilePersistInstance will be stored in the [default Storage](#-d
103103
```ts
104104
storageManager.config.defaultStorageKey; // Returns key of current default Storage
105105
```
106+
107+
## 🌈 Migration
108+
109+
In rare cases it is necessary to format the State value
110+
before it is persisted in an external Storage and migrated back later.
111+
When working with the `Date` class such formatting is required,
112+
since a javascript class can't be persisted.
113+
```ts
114+
const MY_STATE = createState(
115+
{
116+
// ..
117+
birthday: new Date('08.10.202')
118+
}
119+
).persist(
120+
{
121+
key: 'jeff',
122+
onSave: (value) => {
123+
value.date = value.date.getTime()
124+
return value;
125+
},
126+
onMigrate: (value) => {
127+
value.date = new Date(value.date);
128+
return value
129+
}
130+
}
131+
);
132+
```
133+

docs/packages/event/Introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ slug: /event
1010
<a href="https://npm.im/@agile-ts/event">
1111
<img src="https://img.shields.io/npm/v/@agile-ts/event.svg?label=npm&style=flat&colorA=293140&colorB=4a4872" alt="npm version"/></a>
1212
<a href="https://npm.im/@agile-ts/event">
13-
<img src="https://img.shields.io/bundlephobia/min/@agile-ts/event.svg?label=minified%20size&style=flat&colorA=293140&colorB=4a4872" alt="npm minified size"/></a>
13+
<img src="https://img.shields.io/bundlephobia/minzip/@agile-ts/event.svg?label=minified%20size&style=flat&colorA=293140&colorB=4a4872" alt="npm minified size"/></a>
1414
<a href="https://npm.im/@agile-ts/event">
1515
<img src="https://img.shields.io/npm/dt/@agile-ts/event.svg?label=downloads&style=flat&colorA=293140&colorB=4a4872" alt="npm total downloads"/></a>
1616

0 commit comments

Comments
 (0)