@fbltd/async 1.0.19 → 1.0.21
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/dist/bin/dependency-stream/integrations/react/index.js +1 -17
- package/dist/bin/dependency-stream/integrations/react/{src/race-stream.controller.js → race-stream.controller.js} +5 -9
- package/dist/bin/dependency-stream/integrations/react/use-race.stream.js +17 -0
- package/dist/bin/dependency-stream/integrations/react/utils.js +7 -0
- package/dist/types/dependency-stream/integrations/react/index.d.ts +1 -1
- package/dist/types/dependency-stream/integrations/react/{src/race-stream.controller.d.ts → race-stream.controller.d.ts} +1 -1
- package/dist/types/dependency-stream/integrations/react/{src/use-race.stream.d.ts → use-race.stream.d.ts} +1 -1
- package/package.json +6 -2
- package/dist/bin/dependency-stream/integrations/react/src/index.js +0 -22
- package/dist/bin/dependency-stream/integrations/react/src/use-race.stream.js +0 -20
- package/dist/bin/dependency-stream/integrations/react/src/utils.js +0 -10
- package/dist/types/dependency-stream/integrations/react/src/index.d.ts +0 -3
- /package/dist/types/dependency-stream/integrations/react/{src/utils.d.ts → utils.d.ts} +0 -0
|
@@ -1,17 +1 @@
|
|
|
1
|
-
"use
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./src/index.js"), exports);
|
|
1
|
+
export * from "./use-race.stream.js";
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const utils_1 = require("./utils");
|
|
5
|
-
const stream_utils_1 = require("../../../stream-utils");
|
|
6
|
-
class RaceStreamController {
|
|
1
|
+
import { isObjectsContentEqual } from "./utils.js";
|
|
2
|
+
import { raceStream } from "../../stream-utils/index.js";
|
|
3
|
+
export class RaceStreamController {
|
|
7
4
|
_value;
|
|
8
5
|
isFirstWas = false;
|
|
9
6
|
rerenderTrigger;
|
|
@@ -17,7 +14,7 @@ class RaceStreamController {
|
|
|
17
14
|
return this._value;
|
|
18
15
|
}
|
|
19
16
|
async init() {
|
|
20
|
-
this.iterator =
|
|
17
|
+
this.iterator = raceStream(this.deps);
|
|
21
18
|
this._value = Object.entries(this.deps)
|
|
22
19
|
.reduce((acc, [key, dep]) => {
|
|
23
20
|
acc[key] = dep.value;
|
|
@@ -25,7 +22,7 @@ class RaceStreamController {
|
|
|
25
22
|
}, {});
|
|
26
23
|
for await (let value of this.iterator) {
|
|
27
24
|
this.rerenderTrigger?.(prev => !prev);
|
|
28
|
-
if (!this.isFirstWas && !
|
|
25
|
+
if (!this.isFirstWas && !isObjectsContentEqual(this._value, value)) {
|
|
29
26
|
this._value = value;
|
|
30
27
|
}
|
|
31
28
|
this.isFirstWas = true;
|
|
@@ -35,4 +32,3 @@ class RaceStreamController {
|
|
|
35
32
|
this.iterator.dispose();
|
|
36
33
|
};
|
|
37
34
|
}
|
|
38
|
-
exports.RaceStreamController = RaceStreamController;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { RaceStreamController } from "./race-stream.controller.js";
|
|
3
|
+
export function useRaceStream(deps) {
|
|
4
|
+
const [obj] = useState(() => ({ controller: new RaceStreamController(deps) }));
|
|
5
|
+
const [, setValue] = useState(false);
|
|
6
|
+
obj.controller.rerenderTrigger = setValue;
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
return () => {
|
|
9
|
+
obj.controller.dispose();
|
|
10
|
+
obj.controller = undefined;
|
|
11
|
+
};
|
|
12
|
+
}, []);
|
|
13
|
+
return {
|
|
14
|
+
value: obj.controller.value,
|
|
15
|
+
dispose: obj.controller.dispose,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './use-race.stream.ts';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from "react";
|
|
2
|
-
import { IDepObjectArgument, IDepObjectReturn, raceStream } from "
|
|
2
|
+
import { IDepObjectArgument, IDepObjectReturn, raceStream } from "../../stream-utils/index.ts";
|
|
3
3
|
export declare class RaceStreamController<T extends IDepObjectArgument> {
|
|
4
4
|
private _value;
|
|
5
5
|
private isFirstWas;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDepObjectArgument, IDepObjectReturn } from "
|
|
1
|
+
import { IDepObjectArgument, IDepObjectReturn } from "../../index.ts";
|
|
2
2
|
export declare function useRaceStream<T extends IDepObjectArgument>(deps: T): {
|
|
3
3
|
value: IDepObjectReturn<T>;
|
|
4
4
|
dispose: Function;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fbltd/async",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "Miscellaneous async utils",
|
|
5
5
|
"homepage": "https://github.com/GlennMiller1991/async",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"clearDist": "rm dist -rf || true",
|
|
25
25
|
"clearModules": "rm node_modules -rf || true",
|
|
26
26
|
"clearAll": "npm run clearDist && npm run clearModules",
|
|
27
|
-
"build": "
|
|
27
|
+
"build": "npm run clearAll && npm i && mkdir dist && tsc",
|
|
28
28
|
"test": "node --expose-gc node_modules/.bin/jest --config=./__tests__/jest.config.cjs",
|
|
29
29
|
"postVersionCommit": "git commit -m='post version commit' || true",
|
|
30
30
|
"postVersionPush": "git push || true",
|
|
@@ -33,7 +33,11 @@
|
|
|
33
33
|
},
|
|
34
34
|
"author": "",
|
|
35
35
|
"license": "ISC",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"react": "^19.x.x"
|
|
38
|
+
},
|
|
36
39
|
"devDependencies": {
|
|
40
|
+
"@types/react": "^19.x.x",
|
|
37
41
|
"@types/jest": "^30.0.0",
|
|
38
42
|
"jest": "^30.0.4",
|
|
39
43
|
"ts-jest": "^29.4.0",
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.isObjectsContentEqual = exports.RaceStreamController = void 0;
|
|
18
|
-
__exportStar(require("./use-race.stream.js"), exports);
|
|
19
|
-
var race_stream_controller_1 = require("./race-stream.controller");
|
|
20
|
-
Object.defineProperty(exports, "RaceStreamController", { enumerable: true, get: function () { return race_stream_controller_1.RaceStreamController; } });
|
|
21
|
-
var utils_1 = require("./utils");
|
|
22
|
-
Object.defineProperty(exports, "isObjectsContentEqual", { enumerable: true, get: function () { return utils_1.isObjectsContentEqual; } });
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useRaceStream = useRaceStream;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const race_stream_controller_1 = require("./race-stream.controller");
|
|
6
|
-
function useRaceStream(deps) {
|
|
7
|
-
const [obj] = (0, react_1.useState)(() => ({ controller: new race_stream_controller_1.RaceStreamController(deps) }));
|
|
8
|
-
const [, setValue] = (0, react_1.useState)(false);
|
|
9
|
-
obj.controller.rerenderTrigger = setValue;
|
|
10
|
-
(0, react_1.useEffect)(() => {
|
|
11
|
-
return () => {
|
|
12
|
-
obj.controller.dispose();
|
|
13
|
-
obj.controller = undefined;
|
|
14
|
-
};
|
|
15
|
-
}, []);
|
|
16
|
-
return {
|
|
17
|
-
value: obj.controller.value,
|
|
18
|
-
dispose: obj.controller.dispose,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isObjectsContentEqual = isObjectsContentEqual;
|
|
4
|
-
function isObjectsContentEqual(obj1, obj2) {
|
|
5
|
-
for (let key in obj1) {
|
|
6
|
-
if (obj1[key] !== obj2[key])
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
File without changes
|