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

Commit b19a502

Browse files
committed
fixed typos
1 parent 7d44dcc commit b19a502

File tree

6 files changed

+200
-189
lines changed

6 files changed

+200
-189
lines changed

docs/Interfaces.md

Lines changed: 69 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,10 @@ interface AgileHookConfigInterface {
11391139
key?: SubscriptionContainerKeyType;
11401140
agileInstance?: Agile;
11411141
proxyBased?: boolean;
1142+
selector?: SelectorMethodType;
1143+
componentId?: ComponentIdType;
1144+
observerType?: string;
1145+
deps?: any[];
11421146
}
11431147
```
11441148

@@ -1177,38 +1181,17 @@ However, since each Observer has an instance to the Agile Instance, `useAgile()`
11771181

11781182
#### `proxyBased`
11791183

1180-
If the `useAgile()` hook should wrap a [Proxy()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) around its return value/s.
1181-
Through this Proxy, AgileTs is able to track accessed properties of the returned object/s
1182-
and can construct a path to these.
1183-
The paths allow AgileTs to rerender the Component more efficiently
1184-
by only causing a rerender when an actual accessed property value mutates.
1185-
Normally, the Component is always rerendered on a State change,
1186-
regardless of whether the changed property value is accessed in the Component.
1187-
This is totally fine if the value is primitive or the whole object is displayed.
1188-
However, as soon as we display only a tiny part of the bound State value object,
1189-
the proxy feature can reduce the rerender count.
1190-
```ts
1191-
const MY_STATE = App.createState({name: 'frank', age: 10})
1192-
1193-
// -- MyComponent.js ----------------------------------------
1194-
1195-
// Bind State to 'MyComponent.js'
1196-
const myState = useAgile(MY_STATE, {proxyBased: true});
1197-
1198-
return <p>{myState.name}</p>
1184+
:::warning
11991185

1200-
// -- core.js ----------------------------------------------
1186+
Requires an additional package called `@agile-ts/proxytree`!
12011187

1202-
// Causes rerender on 'MyComponent.js',
1203-
// since the '.name' property got accessed
1204-
MY_STATE.patch({name: 'jeff'});
1188+
:::
12051189

1206-
// Doesn't cause rerender on 'MyComponent.js',
1207-
// since the '.age' property didn't got accessed
1208-
MY_STATE.patch({age: 20});
1209-
```
1210-
To avoid having to set the `proxyBased` configuration to `true` every time we use the proxy functionality,
1211-
we can use the [`useProxy()`](packages/react/api/Hooks.md#useproxy) hook which does that part for us.
1190+
Whether to wrap a [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
1191+
around the bound Agile Instance value object,
1192+
to automatically constrain the way the selected Agile Instance
1193+
is compared to determine whether the Component needs to be re-rendered
1194+
based on the object's used properties.
12121195
```ts
12131196
useProxy(MY_STATE);
12141197
// equal to
@@ -1217,57 +1200,85 @@ useAgile(MY_STATE, {proxyBased: true});
12171200

12181201
| Type | Default | Required |
12191202
|--------------------------|-----------|----------|
1220-
| `string \| number` | undefined | No |
1203+
| `boolean` | false | No |
12211204

1205+
<br/>
12221206

1207+
#### `selector`
12231208

1224-
<br/>
1209+
:::warning
12251210

1226-
---
1211+
Note that setting this property can destroy the useAgile type.
1212+
-> should only be used internal!
12271213

1228-
<br/>
1214+
```ts
1215+
useSelector(MY_STATE, (v.name) => v.name);
1216+
// equal to
1217+
useAgile(MY_STATE, {selector: (v.name) => v.name});
1218+
```
12291219

1220+
:::
12301221

1222+
Equality comparison function
1223+
that allows you to customize the way the selected Agile Instance
1224+
is compared to determine whether the Component needs to be re-rendered.
12311225

1232-
## `ProxyHookConfigInterface`
1226+
| Type | Default | Required |
1227+
|--------------------------|-----------|----------|
1228+
| `SelectorMethodType` | undefined | No |
12331229

1234-
The `ProxyHookConfigInterface` is used as configuration object in functions like [`useProxy()`](packages/react/api/Hooks.md#useproxy).
1235-
Here is a Typescript Interface for quick reference. However,
1236-
each property is explained in more detail below.
1230+
<br/>
1231+
1232+
#### `componentId`
1233+
1234+
Key/Name identifier of the UI-Component the Subscription Container is bound to.
12371235
```ts
1238-
interface ProxyHookConfigInterface {
1239-
key?: SubscriptionContainerKeyType;
1240-
agileInstance?: Agile;
1241-
}
1236+
useAgile(MY_STATE, {componentId: 'User.tsx'});
12421237
```
1238+
In future re-render events
1239+
with the same `componentId` are batched,
1240+
in addition to batching re-render events based on the `SubscriptionContainer`.
1241+
1242+
| Type | Default | Required |
1243+
|--------------------------|-----------|----------|
1244+
| `string\|number` | undefined | No |
12431245

12441246
<br/>
12451247

1246-
#### `key`
1248+
#### `observerType`
1249+
1250+
:::warning
1251+
1252+
Note that setting this property can destroy the useAgile type.
1253+
-> should only be used internal!
12471254

1248-
The `key/name` of the [SubscriptionContainer](packages/core/api/integration/Introduction.md#-subscriptions) that is created and added to the Observers.
1249-
```ts
1250-
useProxy(MY_STATE, {key: 'jeff'});
1251-
```
1252-
Such key can be very useful during debug sessions
1253-
in order to analyse when which SubscriptionContainer triggered a rerender on a Component.
12541255
```ts
1255-
// Agile Debug: Registered Callback/Component based Subscription 'jeff', SubscriptionContainer('jeff')
1256-
// Agile Debug: Updated/Rerendered Subscriptions, [SubscriptionContainer('jeff'), ..]
1257-
// Agile Debug: Unregistered Callback/Component based Subscription 'jeff', SubscriptionContainer('jeff')
1256+
useOutput(MY_STATE);
1257+
// equal to
1258+
useAgile(MY_STATE, {observerType: 'output'});
1259+
1260+
useValue(MY_STATE);
1261+
// equal to
1262+
useAgile(MY_STATE, {observerType: 'value'});
12581263
```
12591264

1265+
:::
1266+
1267+
What type of Observer to be bound to the UI-Component.
1268+
12601269
| Type | Default | Required |
12611270
|--------------------------|-----------|----------|
1262-
| `string \| number` | undefined | No |
1271+
| `string` | false | No |
12631272

12641273
<br/>
12651274

1266-
#### `agileInstance`
1275+
#### `deps`
12671276

1268-
The [Agile Instance](packages/core/api/agile-instance/Introduction.md) to which the created [SubscriptionContainer](packages/core/api/integration/Introduction.md#-subscriptions) belongs to.
1269-
However, since each Observer has an instance to the Agile Instance, `useProxy()` can automatically derive the Agile Instance from that.
1277+
Dependencies that determine, in addition to unmounting and remounting the React-Component,
1278+
when the specified Agile Sub Instances should be re-subscribed to the React-Component.
12701279

1271-
| Type | Default | Required |
1272-
|---------------------------------------------------------------------------------|-----------|----------|
1273-
| [Agile Instance](packages/core/api/agile-instance/Introduction.md) | undefined | No |
1280+
Related to [github issue](https://github.com/agile-ts/agile/issues/170).
1281+
1282+
| Type | Default | Required |
1283+
|--------------------------|-----------|----------|
1284+
| `any[]` | [] | No |

docs/packages/react/Installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The `react` package can be installed over [npm](https://www.npmjs.com/).
99

1010
:::warning
1111

12-
Be aware that this is no standalone package!
12+
Note that the `react` package is no standalone package!
1313

1414
:::
1515

@@ -24,6 +24,6 @@ Therefore, we have created a table that shows which versions fit together withou
2424

2525
| @agile-ts/react | @agile-ts/core | NPM Version | Supported React versions | Supports hook based components |
2626
| ---------------- | ----------------------- | ------------------------ | -------------------------|---------------------------------- |
27-
| v0.1.1+ | v0.1.1+ | v6+ | 16.8+ | Yes |
27+
| v0.1.2+ | v0.1.2+ | v6+ | 16.8+ | Yes |
2828

2929
_Older Versions aren't supported anymore_

docs/packages/react/Introduction.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar_label: Introduction
55
slug: /react
66
---
77

8-
> Integration for React or React-Native
8+
> Integration for React and React-Native
99
1010
<br />
1111

@@ -20,47 +20,48 @@ slug: /react
2020

2121
## `react`
2222

23-
The `react` package helps us to integrate AgileTs into a [React](https://reactjs.org/) environment
24-
and serves as an Interface to React.
25-
Its main task is to bind States to React Components.
26-
This binding ensures that AgileTs rerender the Component whenever a bound State mutates.
27-
It also offers some other valuable functionalities
28-
that optimize the workflow using AgileTs in a React project.
23+
The `react` package is a set of utilities that simplifies the way AgileTs is integrated into a [React](https://reactjs.org/) environment.
24+
Think of it as an extension of AgileTs in the context of React
25+
that serves as an interface to React Components.
26+
The main task of the `react` integration is to bind AgileTs States to React Components.
27+
This ensures that AgileTs will re-render the Component when the bound State changes.
28+
It also provides some other valuable functionalities
29+
that optimize the workflow with AgileTs in a React project.
2930

30-
A distinction is made between `Functional` and `Class` Components.
31-
As we prefer to use [`React Hooks`](https://reactjs.org/docs/hooks-intro.html) in Functional Components
32-
but Hooks aren't supported in Class Components.
33-
Therefore, we have created alternatives for Class Components
34-
in order to offer the same functionalities there as well.
31+
A distinction is made between `Functional` and `Class` React Components.
32+
As we prefer to use [`React Hooks`](https://reactjs.org/docs/hooks-intro.html) in Functional Components,
33+
however, Hooks aren't supported in Class Components.
34+
Therefore, we have created alternatives for Class Components
35+
in order to offer the most essential functionalities there as well.
3536

3637
### 🐆 Functional Component
3738

38-
In Functional Components we recommend using AgileTs Hooks like [`useAgile()`](api/Hooks.md#useagile).
39-
The `useAgile()` Hook binds [Agile Sub Instances](../../main/Introduction.md#agile-sub-instance)
40-
(like States or Collections) to React Components.
39+
In `Functional Components` we recommend using AgileTs Hooks like [`useAgile()`](api/Hooks.md#useagile).
40+
The `useAgile()` Hook binds [Agile Sub Instances](../../main/Introduction.md#agile-sub-instance)
41+
(like States or Collections) to React Components for reactivity.
4142
```ts
4243
// -- MyComponent.jsx ------------------------------------------
4344

44-
// Binds MY_FIRST_STATE to 'MyComponent.jsx'
45+
// Binds MY_FIRST_STATE to 'MyComponent.jsx' for reactivity
4546
const myFirstState = useAgile(MY_FIRST_STATE);
4647
```
4748
To find out more about `useAgile()`, and other Hooks provided by AgileTs,
4849
checkout the [AgileTs Hook documentation](api/Hooks.md).
4950

5051
### 🦖 Class Component
5152

52-
For Class Components, we provide the `AgileHOC`.
53+
For `Class Components`, we provide the `AgileHOC`.
5354
The `AgileHOC` is a Higher Order Component that is wrapped around a React Component.
54-
It takes care of binding [Agile Sub Instances](../../main/Introduction.md#agile-sub-instance)
55-
(like States or Collections) to wrapped React Components.
55+
It takes care of binding [Agile Sub Instances](../../main/Introduction.md#agile-sub-instance)
56+
(like States or Collections) to the wrapped React Components for reactivity.
5657
```ts
5758
// -- MyComponent.jsx ------------------------------------------
5859

59-
// Binds MY_FIRST_STATE to 'MyComponent.jsx'
60+
// Binds MY_FIRST_STATE to 'MyComponent.jsx' for reactivyty
6061
export default AgileHOC(myComponent, [MY_FIRST_STATE]);
6162
```
62-
To find out more about the `AgileHOC` and AgileTs in Class Components,
63-
checkout the [AgileHOC documentation](api/AgileHoc.md).
63+
To find out more about the `AgileHOC` and how to correctly use AgileTs in Class Components,
64+
take a look at the [AgileHOC documentation](api/AgileHoc.md).
6465

6566
## 🚀 Quick Links
6667
- [Installation](./Installation.md)

0 commit comments

Comments
 (0)