@fbltd/async 1.0.34 → 1.0.35
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { memo, useEffect, useState } from "react";
|
|
2
2
|
import { observationState } from "../../observe.state.js";
|
|
3
3
|
import { usePromise } from "./utils.js";
|
|
4
4
|
export function Reactive(fn) {
|
|
5
|
-
return
|
|
5
|
+
return memo((props) => {
|
|
6
6
|
const [key, setKey] = useState(false);
|
|
7
7
|
const abortPromise = usePromise();
|
|
8
8
|
useEffect(() => abortPromise.resolve, []);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Dependency } from "../../dependency.js";
|
|
2
2
|
import { symAI } from "../../../constants.js";
|
|
3
3
|
import { runFnWithDepCollection } from "./utils.js";
|
|
4
|
-
import { observationState } from "../../observe.state.js";
|
|
5
4
|
export function reaction(fn, config) {
|
|
6
5
|
let { result, deps } = runFnWithDepCollection(fn);
|
|
7
6
|
const dep = new Dependency(result, config);
|
|
@@ -12,17 +11,13 @@ export function reaction(fn, config) {
|
|
|
12
11
|
let obj = {
|
|
13
12
|
next: async () => {
|
|
14
13
|
depsArray = Array.from(deps);
|
|
15
|
-
|
|
16
|
-
beforeValues = depsArray.map(dep => dep.value);
|
|
14
|
+
beforeValues = depsArray.map(dep => dep.value_unsafe);
|
|
17
15
|
const promises = depsArray.map(dep => dep.next());
|
|
18
16
|
promises.push(dep.disposePromise);
|
|
19
|
-
observationState.cancelSuspense();
|
|
20
17
|
await Promise.race(depsArray.map(dep => dep.next()));
|
|
21
18
|
if (dep.done)
|
|
22
19
|
return { done: true };
|
|
23
|
-
|
|
24
|
-
let shouldRun = depsArray.some((dep, i) => dep.value !== beforeValues[i]);
|
|
25
|
-
observationState.cancelSuspense();
|
|
20
|
+
let shouldRun = depsArray.some((dep, i) => dep.value_unsafe !== beforeValues[i]);
|
|
26
21
|
if (shouldRun) {
|
|
27
22
|
({ result, deps } = runFnWithDepCollection(fn));
|
|
28
23
|
return { done: false, value: result };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fbltd/async",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.35",
|
|
4
4
|
"description": "Miscellaneous async utils",
|
|
5
5
|
"homepage": "https://github.com/GlennMiller1991/async",
|
|
6
6
|
"type": "module",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
},
|
|
34
34
|
"author": "",
|
|
35
35
|
"license": "ISC",
|
|
36
|
-
"peerDependencies": {
|
|
37
|
-
"react": "^19.x.x"
|
|
38
|
-
},
|
|
39
36
|
"devDependencies": {
|
|
40
|
-
"react": "^19.x.x",
|
|
41
37
|
"@types/jest": "^30.0.0",
|
|
42
38
|
"@types/react": "^19.x.x",
|
|
43
39
|
"jest": "^30.0.4",
|
|
40
|
+
"react": "^19.x.x",
|
|
44
41
|
"ts-jest": "^29.4.0",
|
|
45
42
|
"typescript": "^5.x.x"
|
|
46
43
|
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": "^19.1.1"
|
|
46
|
+
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
}
|