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

Commit d824cec

Browse files
authored
Merge pull request #88 from agile-ts/develop
Added basic vue integration docs
2 parents 1505f93 + 33aa2a6 commit d824cec

File tree

14 files changed

+417
-61
lines changed

14 files changed

+417
-61
lines changed

docs/examples/vue/Introduction.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
id: introduction
3+
title: Vue Examples
4+
sidebar_label: Vue
5+
slug: /examples/vue
6+
---
7+
8+
## 🤠 Get Started
9+
- [First State](./vue/first-state)
10+
- [First Collection](./vue/first-collection)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
id: first-collection
3+
title: First Collection
4+
sidebar_label: First Collection
5+
slug: /examples/vue/first-collection
6+
---
7+
8+
import {CodeSandBoxEmbed} from "../../../../src/components/docs/CodeSandBoxEmbed";
9+
10+
<CodeSandBoxEmbed uri={'agilets-first-state-i5xxs'} />
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
id: first-state
3+
title: First State
4+
sidebar_label: First State
5+
slug: /examples/vue/first-state
6+
---
7+
8+
import {CodeSandBoxEmbed} from "../../../../src/components/docs/CodeSandBoxEmbed";
9+
10+
<CodeSandBoxEmbed uri={'agilets-first-state-i5xxs'} />

docs/main/Frameworks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ A quick overview of all frameworks that AgileTs supports or has planned to suppo
1818
| [React](https://reactjs.org) || - |
1919
| [React-Native](https://reactnative.dev/) || - |
2020
| [Angular](https://angular.io/) |||
21-
| [Vue](https://vuejs.org/) | ||
21+
| [Vue](https://vuejs.org/) | 🟨 | |
2222
| [Svelte](https://svelte.dev/) || - |
2323

2424
### 🤖 SSR-Frameworks

docs/main/Introduction.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,23 @@ slug: /introduction/
2424
## 👋 Introduction
2525

2626
AgileTs is a global, simple, well-tested State Management Framework implemented in Typescript.
27-
It offers a reimagined API that focuses on **developer experience** and allows you to **quickly** and **easily** manage your States.
27+
It offers a reimagined API that focuses on **developer experience**
28+
and allows you to **easily** manage your States.
2829
Besides States, AgileTs offers some other powerful APIs that make your life easier.
2930
The philosophy behind AgileTs is simple:
3031

3132
### 🚅 Straightforward
3233
Write minimalistic, boilerplate-free code that captures your intent.
34+
```ts
35+
MY_STATE.set('jeff'); // Update State value
36+
MY_STATE.undo(); // Undo latest State value change
37+
MY_STATE.is({hello: "jeff"}); // Check if State has the value '{hello: "jeff"}'
38+
MY_STATE.watch((value) => {console.log(value);}); // Watch on State changes
39+
```
3340

34-
**Some straightforward syntax examples:**
41+
**Some more straightforward syntax examples:**
3542

36-
- Mutate and Check States with simple Functions
37-
```ts
38-
MY_STATE.undo(); // Undo latest change
39-
MY_STATE.is({hello: "jeff"}); // Check if State has the Value '{hello: "jeff"}'
40-
MY_STATE.watch((value) => {console.log(value);}); // Watch on State changes
41-
```
42-
- Store State in any Storage, like [Local Storage](https://www.w3schools.com/html/html5_webstorage.asp)
43+
- Store State in any Storage, like the [Local Storage](https://www.w3schools.com/html/html5_webstorage.asp)
4344
```ts
4445
MY_STATE.persist("storage-key");
4546
```
@@ -65,18 +66,19 @@ Write minimalistic, boilerplate-free code that captures your intent.
6566
### ⛳️ Centralize
6667

6768
AgileTs is designed to take all business logic out of UI-Components and put them in a central place, often called `core`.
68-
The benefit of keeping logic separate to UI-Components is to make your code more decoupled, portable, and above all, easily testable.
69+
The benefit of keeping logic separate to UI-Components is to make your code more decoupled, portable, scalable, and above all, easily testable.
6970

7071
### 🎯 Easy to Use
7172

7273
Learn the powerful tools of AgileTs in a short amount of time. An excellent place to start are
73-
our [Quick Start](./Installation.md) Guides, or if you don't like to follow any tutorials,
74+
our [Quick Start Guides](./Installation.md), or if you don't like to follow any tutorials,
7475
you can jump straight into our [Example](../examples/Introduction.md) Section.
7576

7677

7778
## ⏳ Quick Example
7879

79-
Instead of talking too much about the benefits of AgileTs, we should start programming.
80+
Instead of talking too much about the benefits of AgileTs,
81+
we should rather see them in action.
8082

8183
### 😎 Create State
8284

@@ -90,13 +92,13 @@ const App = new Agile();
9092
const MY_FIRST_STATE = App.createState("Hello Friend!");
9193

9294

93-
// -- MyComponent.js ------------------------------------------
95+
// -- MyComponent.whatever ------------------------------------------
9496

9597
// 3️⃣ Bind initialized State to desired UI-Component
9698
// And wolla, it's reactive. Everytime the State mutates the Component rerenders
9799
const myFirstState = useAgile(MY_FIRST_STATE); // Returns value of State ("Hello Friend!")
98100
```
99-
To learn out more, check out our [Quick Start Guides](./Installation.md).
101+
Want to learn more? Check out our [Quick Start Guides](https://agile-ts.org/docs/Installation.md).
100102

101103
### ⛳️ Sandbox
102104

@@ -105,10 +107,10 @@ It's only one click away. Just select your preferred Framework below.
105107

106108
- [React](https://codesandbox.io/s/agilets-first-state-f12cz)
107109
- [React-Native](https://snack.expo.io/@bennodev/agilets-first-state)
108-
- Vue (coming soon)
110+
- [Vue](https://codesandbox.io/s/agilets-first-state-i5xxs)
109111
- Angular (coming soon)
110112

111-
More examples can be found in the [Example](../examples/Introduction.md) Section.
113+
More examples can be found in the [Example Section](../examples/Introduction.md).
112114

113115
## 👨‍💻 When using AgileTs
114116

docs/packages/event/Installation.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ Therefore, we have created a table which shows which versions fit together witho
2525
| @agile-ts/event | @agile-ts/core | NPM Version | Supported React versions | Supports hook based components |
2626
| ----------------------| ----------------------- | ------------------------ | -------------------------|---------------------------------- |
2727
| v0.0.1+ | v0.0.10+ | v6+ | 16.8+ | Yes |
28-
_Other Versions aren't supported anymore_
28+
29+
_Older Versions aren't supported anymore_

docs/packages/multieditor/Installation.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ Therefore, we have created a table which shows which versions fit together witho
2626
| ----------------------| ----------------------- | ------------------------ |
2727
| v0.0.7+ | v0.0.7+ | v6+ |
2828
| v0.0.6 | v0.0.3 - v0.0.6 | v6+ |
29-
_Other Versions aren't supported anymore_
29+
30+
_Older Versions aren't supported anymore_

docs/packages/react/Installation.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ which functions as the brain of AgileTs and is indispensable.
2222
Unfortunately, we can't combine each `core` with `react` version.
2323
Therefore, we have created a table that shows which versions fit together without restrictions.
2424

25-
| @agile-ts/react | @agile-ts/core | NPM Version | Supported React versions | Supports hook based components |
26-
| --------------- | ----------------------- | ------------------------ | -------------------------|---------------------------------- |
27-
| v0.0.7+ | v0.0.7+ | v6+ | 16.8+ | Yes |
28-
| v0.0.6 | v0.0.3 - v0.0.6 | v6+ | 16.8+ | Yes |
29-
_Older Versions aren't supported anymore_
25+
| @agile-ts/react | @agile-ts/core | NPM Version | Supported React versions | Supports hook based components |
26+
| ---------------- | ----------------------- | ------------------------ | -------------------------|---------------------------------- |
27+
| v0.0.15+ | v0.0.16+ | v6+ | 16.8+ | Yes |
28+
| v0.0.7 - v0.0.14 | v0.0.7 - v0.0.15 | v6+ | 16.8+ | Yes |
29+
30+
_Older Versions aren't supported anymore_

docs/packages/vue/Installation.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
id: installation
3+
title: Installation
4+
sidebar_label: Installation
5+
slug: /vue/installation
6+
---
7+
8+
The `vue` package can be installed over [npm](https://www.npmjs.com/).
9+
10+
:::warning
11+
12+
Be aware that this is no standalone package!
13+
14+
:::
15+
16+
```bash npm2yarn
17+
npm install @agile-ts/vue
18+
```
19+
20+
The `vue` package is an extension of AgileTs and doesn't work without the [`core`](../core/Introduction.md) package,
21+
which functions as the brain of AgileTs and is indispensable.
22+
Unfortunately, we can't combine each `core` with `vue` version.
23+
Therefore, we have created a table that shows which versions fit together without restrictions.
24+
25+
| @agile-ts/vue | @agile-ts/core | NPM Version | Supported Vue versions |
26+
| ---------------- | ----------------------- | ------------------------ | -------------------------|
27+
| v0.0.01+ | v0.0.16+ | v6+ | 2.x (3.x not tested) |
28+
29+
_Older Versions aren't supported anymore_

docs/packages/vue/Introduction.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
id: introduction
3+
title: Introduction
4+
sidebar_label: Introduction
5+
slug: /vue
6+
---
7+
8+
:::warning
9+
10+
WIP Package!
11+
12+
:::
13+
14+
> Integration for Vue
15+
16+
<br />
17+
18+
<a href="https://github.com/agile-ts/agile">
19+
<img src="https://img.shields.io/github/license/agile-ts/agile.svg?label=license&style=flat&colorA=293140&colorB=4a4872" alt="GitHub License"/></a>
20+
<a href="https://npm.im/@agile-ts/vue">
21+
<img src="https://img.shields.io/npm/v/@agile-ts/vue.svg?label=npm&style=flat&colorA=293140&colorB=4a4872" alt="npm version"/></a>
22+
<a href="https://npm.im/@agile-ts/vue">
23+
<img src="https://img.shields.io/bundlephobia/min/@agile-ts/vue.svg?label=minified%20size&style=flat&colorA=293140&colorB=4a4872" alt="npm minified size"/></a>
24+
<a href="https://npm.im/@agile-ts/vue">
25+
<img src="https://img.shields.io/npm/dt/@agile-ts/vue.svg?label=downloads&style=flat&colorA=293140&colorB=4a4872" alt="npm total downloads"/></a>
26+
27+
## `vue`
28+
29+
The `vue` package helps us to integrate AgileTs into a [Vue](https://vuejs.org/) environment
30+
and serves as an Interface to Vue.
31+
Its main task is to bind States to Vue Components.
32+
This binding ensures that AgileTs rerender the Component whenever a bound State mutates.
33+
It also offers some other valuable functionalities that optimize the workflow using AgileTs in a Vue project.
34+
35+
### `bindAgileInstances()`
36+
37+
The `bindAgileInstances()` method binds/subscribes States to Vue Components.
38+
This binding ensures that the Component rerenders whenever a bound State mutates.
39+
We can flexibly bind any State to any Vue Component.
40+
```ts {4-7}
41+
export default {
42+
name: 'MyComponent',
43+
data: function () {
44+
return {
45+
...this.bindAgileInstances({
46+
myState: MY_STATE,
47+
}),
48+
};
49+
},
50+
};
51+
```
52+
`bindAgileInstances()` returns a State value keymap based on the passed States.
53+
We merge the returned keymap into the `data` object
54+
to access the State `values` in the `html` code like we would local Vue States.
55+
```vue {3}
56+
<template>
57+
<div id="app">
58+
<p>myState: {{ sharedState.myState }}</p>
59+
</div>
60+
</template>
61+
```
62+
Note that the AgileTs State `values` are under the `sharedState` property located
63+
to separate them from the local Vue States.
64+
```ts {4-7}
65+
const MY_STATE = App.createState('jeff');
66+
const MY_STATE_2 = App.createState('frank');
67+
68+
this.bindAgileInstances({
69+
myState: MY_STATE,
70+
myState2: MY_STATE_2,
71+
}); // Returns '{myState: 'jeff', mayState2: 'frank'}'
72+
```
73+
Instead of a States keymap we can also pass an array of States.
74+
But keep in mind that then the passed States require a unique `key`
75+
to be properly mapped into the returned State `value` keymap.
76+
```ts {4-7}
77+
const MY_STATE = App.createState('jeff', {key: 'myState'});
78+
const MY_STATE_2 = App.createState('frank');
79+
80+
this.bindAgileInstances([
81+
MY_STATE,
82+
MY_STATE_2,
83+
]); // Returns '{myState: 'jeff'}'
84+
```
85+
Passed States without a valid `key` are ignored
86+
and won't be represented by the returned keymap.
87+
Thus, the State `value` isn't accessible in the `html` code,
88+
and a State mutation rerender is triggered via. `vueComponent.forceRerender()`
89+
instead of mutating the `data` object.
90+
91+
### 🟦 Typescript
92+
93+
The `bindAgileInstances` isn't typesafe yet. But we are working on it.
94+
95+
## 🚀 Quick Links
96+
- [Installation](./Installation.md)
97+

0 commit comments

Comments
 (0)