dphelper 1.9.69 → 1.9.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/docs/index.md +17 -0
- package/documents/USEOBSERVER.md +30 -0
- package/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
2. [Store](#store)
|
|
34
34
|
3. [Session](#session)
|
|
35
35
|
4. [Observer](#observer)
|
|
36
|
+
5. [useObserver](#useobserver)
|
|
36
37
|
5. [Extension](#extension)
|
|
37
38
|
6. [Security](#security)
|
|
38
39
|
7. [License](#license)
|
|
@@ -126,6 +127,7 @@ You can see:
|
|
|
126
127
|
* [State](https://a51.gitbook.io/dphelper/general/state)
|
|
127
128
|
* [Store](https://a51.gitbook.io/dphelper/general/store)
|
|
128
129
|
* [Observer](https://a51.gitbook.io/dphelper/general/observer)
|
|
130
|
+
* [useObserver](https://a51.gitbook.io/dphelper/general/useobserver)
|
|
129
131
|
* [List of functions](https://a51.gitbook.io/dphelper/general/tools)
|
|
130
132
|
|
|
131
133
|
You can see more tutorials, information, and examples about **dpHelper** [clicking here](https://a51.gitbook.io/dphelper).
|
|
@@ -224,6 +226,21 @@ observer('myData', () => {
|
|
|
224
226
|
state.myData = 'New value';
|
|
225
227
|
```
|
|
226
228
|
|
|
229
|
+
## useObserver
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
import 'dphelper';
|
|
233
|
+
|
|
234
|
+
// Use the useObserver to log the changing state value
|
|
235
|
+
useObserver(
|
|
236
|
+
() => console.log("State changed: ", state.count)
|
|
237
|
+
, 'state.count'
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
// Store a value in the state that changes every 5 seconds
|
|
241
|
+
setInterval(() => state.count = Date.now(), 5000);
|
|
242
|
+
```
|
|
243
|
+
|
|
227
244
|
## Store
|
|
228
245
|
|
|
229
246
|
### Persistent Storage with dpHelper
|
package/docs/index.md
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
2. [Store](#store)
|
|
34
34
|
3. [Session](#session)
|
|
35
35
|
4. [Observer](#observer)
|
|
36
|
+
5. [useObserver](#useobserver)
|
|
36
37
|
5. [Extension](#extension)
|
|
37
38
|
6. [Security](#security)
|
|
38
39
|
7. [License](#license)
|
|
@@ -126,6 +127,7 @@ You can see:
|
|
|
126
127
|
* [State](https://a51.gitbook.io/dphelper/general/state)
|
|
127
128
|
* [Store](https://a51.gitbook.io/dphelper/general/store)
|
|
128
129
|
* [Observer](https://a51.gitbook.io/dphelper/general/observer)
|
|
130
|
+
* [useObserver](https://a51.gitbook.io/dphelper/general/useobserver)
|
|
129
131
|
* [List of functions](https://a51.gitbook.io/dphelper/general/tools)
|
|
130
132
|
|
|
131
133
|
You can see more tutorials, information, and examples about **dpHelper** [clicking here](https://a51.gitbook.io/dphelper).
|
|
@@ -224,6 +226,21 @@ observer('myData', () => {
|
|
|
224
226
|
state.myData = 'New value';
|
|
225
227
|
```
|
|
226
228
|
|
|
229
|
+
## useObserver
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
import 'dphelper';
|
|
233
|
+
|
|
234
|
+
// Use the useObserver to log the changing state value
|
|
235
|
+
useObserver(
|
|
236
|
+
() => console.log("State changed: ", state.count)
|
|
237
|
+
, 'state.count'
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
// Store a value in the state that changes every 5 seconds
|
|
241
|
+
setInterval(() => state.count = Date.now(), 5000);
|
|
242
|
+
```
|
|
243
|
+
|
|
227
244
|
## Store
|
|
228
245
|
|
|
229
246
|
### Persistent Storage with dpHelper
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# useObserver
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document provides a comprehensive list of all available useObserver functions in the `dpHelper` library along with their descriptions and examples.
|
|
6
|
+
|
|
7
|
+
## Functions
|
|
8
|
+
|
|
9
|
+
### useObserver(()=>{ YOUR CODE }, "state.name")
|
|
10
|
+
|
|
11
|
+
- **Description:** Sets up an useObserver to monitor state changes and trigger a callback.
|
|
12
|
+
- **Parameters:**
|
|
13
|
+
- `stateName` (string): The name of the state to monitor.
|
|
14
|
+
- `callBack` (Function): The callback function to run when the state changes.
|
|
15
|
+
- `option` (object): Additional options for the useObserver.
|
|
16
|
+
|
|
17
|
+
- **Example:**
|
|
18
|
+
> The format is really similar to React useEffect
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
useObserver(
|
|
22
|
+
() => {
|
|
23
|
+
console.log('State changed:', newValue);
|
|
24
|
+
}, 'state.test'
|
|
25
|
+
);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
This project is licensed under the Private License.
|