@fbltd/async 1.0.34 → 1.0.36

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.
@@ -34,6 +34,9 @@ export class Dependency {
34
34
  observationState.setDep(this);
35
35
  return this._value;
36
36
  }
37
+ get value_unsafe() {
38
+ return this._value;
39
+ }
37
40
  get done() {
38
41
  return this.abortPromise.isFulfilled;
39
42
  }
@@ -1,8 +1,8 @@
1
- import React, { useEffect, useState } from "react";
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 React.memo((props) => {
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
- observationState.suspend();
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
- observationState.suspend();
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 };
@@ -9,6 +9,7 @@ export declare class Dependency<T = any> {
9
9
  private _set;
10
10
  set value(v: T);
11
11
  get value(): T;
12
+ get value_unsafe(): T;
12
13
  get done(): boolean;
13
14
  [symAI](this: Dependency<T>, thisStreamConfig?: IThisStreamConfig): IStreamIterator<T>;
14
15
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fbltd/async",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
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.x.x"
46
+ },
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  }