@flexsurfer/reflex 0.1.9 → 0.1.10
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/index.cjs +7 -13
- package/dist/index.mjs +7 -13
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -834,7 +834,6 @@ var Reaction = class _Reaction {
|
|
|
834
834
|
version = 0;
|
|
835
835
|
depsVersions = [];
|
|
836
836
|
subVector;
|
|
837
|
-
componentName;
|
|
838
837
|
constructor(computeFn, deps) {
|
|
839
838
|
this.computeFn = computeFn;
|
|
840
839
|
this.deps = deps;
|
|
@@ -851,10 +850,10 @@ var Reaction = class _Reaction {
|
|
|
851
850
|
this.recomputeIfNeeded(notifyWatchers);
|
|
852
851
|
return [this.value, this.version];
|
|
853
852
|
}
|
|
854
|
-
watch(callback) {
|
|
855
|
-
const idx = this.watchers.
|
|
853
|
+
watch(callback, componentName = "react component") {
|
|
854
|
+
const idx = this.watchers.findIndex((w) => w.callback === callback);
|
|
856
855
|
if (idx === -1) {
|
|
857
|
-
this.watchers.push(callback);
|
|
856
|
+
this.watchers.push({ callback, componentName });
|
|
858
857
|
if (this.deps) {
|
|
859
858
|
for (const d of this.deps)
|
|
860
859
|
d.ensureAliveWith(this);
|
|
@@ -862,7 +861,7 @@ var Reaction = class _Reaction {
|
|
|
862
861
|
}
|
|
863
862
|
}
|
|
864
863
|
unwatch(fn) {
|
|
865
|
-
const idx = this.watchers.
|
|
864
|
+
const idx = this.watchers.findIndex((w) => w.callback === fn);
|
|
866
865
|
if (idx !== -1) {
|
|
867
866
|
this.watchers.splice(idx, 1);
|
|
868
867
|
if (this.watchers.length === 0) {
|
|
@@ -926,11 +925,10 @@ var Reaction = class _Reaction {
|
|
|
926
925
|
withTrace(
|
|
927
926
|
{
|
|
928
927
|
opType: "render",
|
|
929
|
-
operation:
|
|
930
|
-
tags: this.componentName ? { componentName: this.componentName } : {}
|
|
928
|
+
operation: w.componentName
|
|
931
929
|
},
|
|
932
930
|
() => {
|
|
933
|
-
w(this.value);
|
|
931
|
+
w.callback(this.value);
|
|
934
932
|
}
|
|
935
933
|
);
|
|
936
934
|
} catch (error) {
|
|
@@ -1014,9 +1012,6 @@ var Reaction = class _Reaction {
|
|
|
1014
1012
|
get isRoot() {
|
|
1015
1013
|
return this.deps === void 0 || this.deps.length === 0;
|
|
1016
1014
|
}
|
|
1017
|
-
setComponentName(componentName) {
|
|
1018
|
-
this.componentName = componentName;
|
|
1019
|
-
}
|
|
1020
1015
|
};
|
|
1021
1016
|
|
|
1022
1017
|
// src/subs.ts
|
|
@@ -1121,8 +1116,7 @@ function useSubscription(subVector, componentName = "react component") {
|
|
|
1121
1116
|
const reaction = getOrCreateReaction(subVector);
|
|
1122
1117
|
if (!reaction)
|
|
1123
1118
|
return;
|
|
1124
|
-
reaction.
|
|
1125
|
-
reaction.watch(setVal);
|
|
1119
|
+
reaction.watch(setVal, componentName);
|
|
1126
1120
|
return () => {
|
|
1127
1121
|
reaction.unwatch(setVal);
|
|
1128
1122
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -766,7 +766,6 @@ var Reaction = class _Reaction {
|
|
|
766
766
|
version = 0;
|
|
767
767
|
depsVersions = [];
|
|
768
768
|
subVector;
|
|
769
|
-
componentName;
|
|
770
769
|
constructor(computeFn, deps) {
|
|
771
770
|
this.computeFn = computeFn;
|
|
772
771
|
this.deps = deps;
|
|
@@ -783,10 +782,10 @@ var Reaction = class _Reaction {
|
|
|
783
782
|
this.recomputeIfNeeded(notifyWatchers);
|
|
784
783
|
return [this.value, this.version];
|
|
785
784
|
}
|
|
786
|
-
watch(callback) {
|
|
787
|
-
const idx = this.watchers.
|
|
785
|
+
watch(callback, componentName = "react component") {
|
|
786
|
+
const idx = this.watchers.findIndex((w) => w.callback === callback);
|
|
788
787
|
if (idx === -1) {
|
|
789
|
-
this.watchers.push(callback);
|
|
788
|
+
this.watchers.push({ callback, componentName });
|
|
790
789
|
if (this.deps) {
|
|
791
790
|
for (const d of this.deps)
|
|
792
791
|
d.ensureAliveWith(this);
|
|
@@ -794,7 +793,7 @@ var Reaction = class _Reaction {
|
|
|
794
793
|
}
|
|
795
794
|
}
|
|
796
795
|
unwatch(fn) {
|
|
797
|
-
const idx = this.watchers.
|
|
796
|
+
const idx = this.watchers.findIndex((w) => w.callback === fn);
|
|
798
797
|
if (idx !== -1) {
|
|
799
798
|
this.watchers.splice(idx, 1);
|
|
800
799
|
if (this.watchers.length === 0) {
|
|
@@ -858,11 +857,10 @@ var Reaction = class _Reaction {
|
|
|
858
857
|
withTrace(
|
|
859
858
|
{
|
|
860
859
|
opType: "render",
|
|
861
|
-
operation:
|
|
862
|
-
tags: this.componentName ? { componentName: this.componentName } : {}
|
|
860
|
+
operation: w.componentName
|
|
863
861
|
},
|
|
864
862
|
() => {
|
|
865
|
-
w(this.value);
|
|
863
|
+
w.callback(this.value);
|
|
866
864
|
}
|
|
867
865
|
);
|
|
868
866
|
} catch (error) {
|
|
@@ -946,9 +944,6 @@ var Reaction = class _Reaction {
|
|
|
946
944
|
get isRoot() {
|
|
947
945
|
return this.deps === void 0 || this.deps.length === 0;
|
|
948
946
|
}
|
|
949
|
-
setComponentName(componentName) {
|
|
950
|
-
this.componentName = componentName;
|
|
951
|
-
}
|
|
952
947
|
};
|
|
953
948
|
|
|
954
949
|
// src/subs.ts
|
|
@@ -1053,8 +1048,7 @@ function useSubscription(subVector, componentName = "react component") {
|
|
|
1053
1048
|
const reaction = getOrCreateReaction(subVector);
|
|
1054
1049
|
if (!reaction)
|
|
1055
1050
|
return;
|
|
1056
|
-
reaction.
|
|
1057
|
-
reaction.watch(setVal);
|
|
1051
|
+
reaction.watch(setVal, componentName);
|
|
1058
1052
|
return () => {
|
|
1059
1053
|
reaction.unwatch(setVal);
|
|
1060
1054
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flexsurfer/reflex",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/flexsurfer/reflex.git"
|
|
7
|
+
"url": "git+https://github.com/flexsurfer/reflex.git"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "dist/index.cjs",
|
|
@@ -68,4 +68,4 @@
|
|
|
68
68
|
"pubsub",
|
|
69
69
|
"handler"
|
|
70
70
|
]
|
|
71
|
-
}
|
|
71
|
+
}
|