@flexsurfer/reflex 0.1.22 → 0.1.24
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 +84 -49
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +84 -49
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -127,12 +127,16 @@ function clearHandlers(kind, id) {
|
|
|
127
127
|
for (const k in kindToIdToHandler) {
|
|
128
128
|
kindToIdToHandler[k] = {};
|
|
129
129
|
}
|
|
130
|
+
clearRootSubSources();
|
|
130
131
|
} else if (id == null) {
|
|
131
132
|
if (!(kind in kindToIdToHandler)) {
|
|
132
133
|
consoleLog("error", `[reflex] Unknown kind: ${kind}`);
|
|
133
134
|
return;
|
|
134
135
|
}
|
|
135
136
|
kindToIdToHandler[kind] = {};
|
|
137
|
+
if (kind === "sub") {
|
|
138
|
+
clearRootSubSources();
|
|
139
|
+
}
|
|
136
140
|
} else {
|
|
137
141
|
if (kindToIdToHandler[kind][id]) {
|
|
138
142
|
delete kindToIdToHandler[kind][id];
|
|
@@ -161,6 +165,16 @@ function clearReactions(id) {
|
|
|
161
165
|
reactionsRegistry.delete(id);
|
|
162
166
|
}
|
|
163
167
|
}
|
|
168
|
+
var rootSubIdBySource = /* @__PURE__ */ new Map();
|
|
169
|
+
function setRootSubSource(subId, sourceKey) {
|
|
170
|
+
rootSubIdBySource.set(sourceKey, subId);
|
|
171
|
+
}
|
|
172
|
+
function getRootSubIdBySource(sourceKey) {
|
|
173
|
+
return rootSubIdBySource.get(sourceKey);
|
|
174
|
+
}
|
|
175
|
+
function clearRootSubSources() {
|
|
176
|
+
rootSubIdBySource.clear();
|
|
177
|
+
}
|
|
164
178
|
function clearSubs() {
|
|
165
179
|
clearReactions();
|
|
166
180
|
clearHandlers("sub");
|
|
@@ -230,7 +244,14 @@ function updateAppDbWithPatches(newDb, patches) {
|
|
|
230
244
|
const pathSegments = patch.path;
|
|
231
245
|
if (pathSegments.length > 0) {
|
|
232
246
|
const rootKey = pathSegments[0];
|
|
233
|
-
|
|
247
|
+
if (typeof rootKey !== "string") {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const subId = getRootSubIdBySource(rootKey);
|
|
251
|
+
if (!subId) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
const subVectorKey = JSON.stringify([subId]);
|
|
234
255
|
const reaction = getReaction(subVectorKey);
|
|
235
256
|
if (reaction) {
|
|
236
257
|
if (!reaction.isRoot) {
|
|
@@ -259,6 +280,51 @@ function updateAppDbWithPatches(newDb, patches) {
|
|
|
259
280
|
|
|
260
281
|
// src/immer-utils.ts
|
|
261
282
|
var import_immer = require("immer");
|
|
283
|
+
|
|
284
|
+
// src/settings.ts
|
|
285
|
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
|
|
286
|
+
var store = {
|
|
287
|
+
globalInterceptors: [],
|
|
288
|
+
globalEqualityCheck: import_fast_deep_equal.default
|
|
289
|
+
};
|
|
290
|
+
function replaceGlobalInterceptor(globalInterceptors, interceptor) {
|
|
291
|
+
return globalInterceptors.reduce((ret, existingInterceptor) => {
|
|
292
|
+
if (interceptor.id === existingInterceptor.id) {
|
|
293
|
+
return [...ret, interceptor];
|
|
294
|
+
} else {
|
|
295
|
+
return [...ret, existingInterceptor];
|
|
296
|
+
}
|
|
297
|
+
}, []);
|
|
298
|
+
}
|
|
299
|
+
function regGlobalInterceptor(interceptor) {
|
|
300
|
+
const { id } = interceptor;
|
|
301
|
+
const ids = store.globalInterceptors.map((i) => i.id);
|
|
302
|
+
if (ids.includes(id)) {
|
|
303
|
+
store.globalInterceptors = replaceGlobalInterceptor(store.globalInterceptors, interceptor);
|
|
304
|
+
} else {
|
|
305
|
+
store.globalInterceptors = [...store.globalInterceptors, interceptor];
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function getGlobalInterceptors() {
|
|
309
|
+
return [...store.globalInterceptors];
|
|
310
|
+
}
|
|
311
|
+
function clearGlobalInterceptors(id) {
|
|
312
|
+
if (id === void 0) {
|
|
313
|
+
store.globalInterceptors = [];
|
|
314
|
+
} else {
|
|
315
|
+
store.globalInterceptors = store.globalInterceptors.filter((interceptor) => interceptor.id !== id);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function setGlobalEqualityCheck(equalityCheck) {
|
|
319
|
+
store.globalEqualityCheck = equalityCheck;
|
|
320
|
+
}
|
|
321
|
+
function getGlobalEqualityCheck() {
|
|
322
|
+
return store.globalEqualityCheck;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/immer-utils.ts
|
|
326
|
+
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"), 1);
|
|
327
|
+
var import_es6 = __toESM(require("fast-deep-equal/es6/index.js"), 1);
|
|
262
328
|
function original(value) {
|
|
263
329
|
return (0, import_immer.isDraft)(value) ? (0, import_immer.original)(value) : value;
|
|
264
330
|
}
|
|
@@ -267,6 +333,9 @@ function current(value) {
|
|
|
267
333
|
}
|
|
268
334
|
function enableMapSet() {
|
|
269
335
|
(0, import_immer.enableMapSet)();
|
|
336
|
+
if (getGlobalEqualityCheck() === import_fast_deep_equal2.default) {
|
|
337
|
+
setGlobalEqualityCheck(import_es6.default);
|
|
338
|
+
}
|
|
270
339
|
}
|
|
271
340
|
|
|
272
341
|
// src/interceptor.ts
|
|
@@ -604,47 +673,6 @@ regEffect(DISPATCH, (value) => {
|
|
|
604
673
|
// src/events.ts
|
|
605
674
|
var import_immer2 = require("immer");
|
|
606
675
|
|
|
607
|
-
// src/settings.ts
|
|
608
|
-
var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
|
|
609
|
-
var store = {
|
|
610
|
-
globalInterceptors: [],
|
|
611
|
-
globalEqualityCheck: import_fast_deep_equal.default
|
|
612
|
-
};
|
|
613
|
-
function replaceGlobalInterceptor(globalInterceptors, interceptor) {
|
|
614
|
-
return globalInterceptors.reduce((ret, existingInterceptor) => {
|
|
615
|
-
if (interceptor.id === existingInterceptor.id) {
|
|
616
|
-
return [...ret, interceptor];
|
|
617
|
-
} else {
|
|
618
|
-
return [...ret, existingInterceptor];
|
|
619
|
-
}
|
|
620
|
-
}, []);
|
|
621
|
-
}
|
|
622
|
-
function regGlobalInterceptor(interceptor) {
|
|
623
|
-
const { id } = interceptor;
|
|
624
|
-
const ids = store.globalInterceptors.map((i) => i.id);
|
|
625
|
-
if (ids.includes(id)) {
|
|
626
|
-
store.globalInterceptors = replaceGlobalInterceptor(store.globalInterceptors, interceptor);
|
|
627
|
-
} else {
|
|
628
|
-
store.globalInterceptors = [...store.globalInterceptors, interceptor];
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
function getGlobalInterceptors() {
|
|
632
|
-
return [...store.globalInterceptors];
|
|
633
|
-
}
|
|
634
|
-
function clearGlobalInterceptors(id) {
|
|
635
|
-
if (id === void 0) {
|
|
636
|
-
store.globalInterceptors = [];
|
|
637
|
-
} else {
|
|
638
|
-
store.globalInterceptors = store.globalInterceptors.filter((interceptor) => interceptor.id !== id);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
function setGlobalEqualityCheck(equalityCheck) {
|
|
642
|
-
store.globalEqualityCheck = equalityCheck;
|
|
643
|
-
}
|
|
644
|
-
function getGlobalEqualityCheck() {
|
|
645
|
-
return store.globalEqualityCheck;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
676
|
// src/trace.ts
|
|
649
677
|
var nextId = 1;
|
|
650
678
|
var traces = [];
|
|
@@ -879,7 +907,7 @@ function defaultErrorHandler(originalError, reflexError) {
|
|
|
879
907
|
regEventErrorHandler(defaultErrorHandler);
|
|
880
908
|
|
|
881
909
|
// src/reaction.ts
|
|
882
|
-
var
|
|
910
|
+
var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"), 1);
|
|
883
911
|
var Reaction = class _Reaction {
|
|
884
912
|
id = "";
|
|
885
913
|
computeFn;
|
|
@@ -896,7 +924,7 @@ var Reaction = class _Reaction {
|
|
|
896
924
|
constructor(computeFn, deps, equalityCheck) {
|
|
897
925
|
this.computeFn = computeFn;
|
|
898
926
|
this.deps = deps;
|
|
899
|
-
this.equalityCheck = equalityCheck ||
|
|
927
|
+
this.equalityCheck = equalityCheck || import_fast_deep_equal3.default;
|
|
900
928
|
}
|
|
901
929
|
static create(fn, deps, equalityCheck) {
|
|
902
930
|
return new _Reaction(fn, deps, equalityCheck);
|
|
@@ -965,7 +993,7 @@ var Reaction = class _Reaction {
|
|
|
965
993
|
const depValues = this.deps?.map((d) => d.getDepValue(notifyWatchers)) ?? [];
|
|
966
994
|
const values = depValues.map(([value]) => value);
|
|
967
995
|
const currentVersions = depValues.map(([, version]) => version);
|
|
968
|
-
const versionsChanged = !(0,
|
|
996
|
+
const versionsChanged = !(0, import_fast_deep_equal3.default)(currentVersions, this.depsVersions);
|
|
969
997
|
if (this.value === void 0 || versionsChanged) {
|
|
970
998
|
let newVal = this.computeFn(...values);
|
|
971
999
|
changed = !this.equalityCheck(newVal, this.value);
|
|
@@ -1082,16 +1110,23 @@ var Reaction = class _Reaction {
|
|
|
1082
1110
|
// src/subs.ts
|
|
1083
1111
|
var KIND4 = "sub";
|
|
1084
1112
|
var KIND_DEPS = "subDeps";
|
|
1113
|
+
function registerRootSub(id, sourceKey) {
|
|
1114
|
+
const conflictingSubId = getRootSubIdBySource(sourceKey);
|
|
1115
|
+
if (conflictingSubId && conflictingSubId !== id) {
|
|
1116
|
+
consoleLog("error", `[reflex] Subscription with id '${id}' will be overridden. Root key '${sourceKey}' is already used by subscription '${conflictingSubId}'.`);
|
|
1117
|
+
}
|
|
1118
|
+
setRootSubSource(id, sourceKey);
|
|
1119
|
+
registerHandler(KIND4, id, () => getAppDb()[sourceKey]);
|
|
1120
|
+
registerHandler(KIND_DEPS, id, () => []);
|
|
1121
|
+
}
|
|
1085
1122
|
function regSub(id, computeFn, depsFn, config) {
|
|
1086
1123
|
if (hasHandler(KIND4, id)) {
|
|
1087
1124
|
consoleLog("warn", `[reflex] Overriding. Subscription '${id}' already registered.`);
|
|
1088
1125
|
}
|
|
1089
1126
|
if (!computeFn) {
|
|
1090
|
-
|
|
1091
|
-
registerHandler(KIND_DEPS, id, () => []);
|
|
1127
|
+
registerRootSub(id, id);
|
|
1092
1128
|
} else if (typeof computeFn === "string") {
|
|
1093
|
-
|
|
1094
|
-
registerHandler(KIND_DEPS, id, () => []);
|
|
1129
|
+
registerRootSub(id, computeFn);
|
|
1095
1130
|
} else {
|
|
1096
1131
|
if (!depsFn) {
|
|
1097
1132
|
consoleLog("error", `[reflex] Subscription '${id}' has computeFn but missing depsFn. Computed subscriptions must specify their dependencies.`);
|
package/dist/index.d.cts
CHANGED
|
@@ -65,6 +65,8 @@ declare function current<T>(value: T): T;
|
|
|
65
65
|
/**
|
|
66
66
|
* Enable Map and Set support in Immer
|
|
67
67
|
* This allows Immer to handle Map and Set objects properly in drafts
|
|
68
|
+
* Also updates the global equality check to use fast-deep-equal/es6 for proper Map/Set comparison,
|
|
69
|
+
* but only if the current equality check is still the default isEqual
|
|
68
70
|
*/
|
|
69
71
|
declare function enableMapSet(): void;
|
|
70
72
|
|
package/dist/index.d.ts
CHANGED
|
@@ -65,6 +65,8 @@ declare function current<T>(value: T): T;
|
|
|
65
65
|
/**
|
|
66
66
|
* Enable Map and Set support in Immer
|
|
67
67
|
* This allows Immer to handle Map and Set objects properly in drafts
|
|
68
|
+
* Also updates the global equality check to use fast-deep-equal/es6 for proper Map/Set comparison,
|
|
69
|
+
* but only if the current equality check is still the default isEqual
|
|
68
70
|
*/
|
|
69
71
|
declare function enableMapSet(): void;
|
|
70
72
|
|
package/dist/index.mjs
CHANGED
|
@@ -49,12 +49,16 @@ function clearHandlers(kind, id) {
|
|
|
49
49
|
for (const k in kindToIdToHandler) {
|
|
50
50
|
kindToIdToHandler[k] = {};
|
|
51
51
|
}
|
|
52
|
+
clearRootSubSources();
|
|
52
53
|
} else if (id == null) {
|
|
53
54
|
if (!(kind in kindToIdToHandler)) {
|
|
54
55
|
consoleLog("error", `[reflex] Unknown kind: ${kind}`);
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
57
58
|
kindToIdToHandler[kind] = {};
|
|
59
|
+
if (kind === "sub") {
|
|
60
|
+
clearRootSubSources();
|
|
61
|
+
}
|
|
58
62
|
} else {
|
|
59
63
|
if (kindToIdToHandler[kind][id]) {
|
|
60
64
|
delete kindToIdToHandler[kind][id];
|
|
@@ -83,6 +87,16 @@ function clearReactions(id) {
|
|
|
83
87
|
reactionsRegistry.delete(id);
|
|
84
88
|
}
|
|
85
89
|
}
|
|
90
|
+
var rootSubIdBySource = /* @__PURE__ */ new Map();
|
|
91
|
+
function setRootSubSource(subId, sourceKey) {
|
|
92
|
+
rootSubIdBySource.set(sourceKey, subId);
|
|
93
|
+
}
|
|
94
|
+
function getRootSubIdBySource(sourceKey) {
|
|
95
|
+
return rootSubIdBySource.get(sourceKey);
|
|
96
|
+
}
|
|
97
|
+
function clearRootSubSources() {
|
|
98
|
+
rootSubIdBySource.clear();
|
|
99
|
+
}
|
|
86
100
|
function clearSubs() {
|
|
87
101
|
clearReactions();
|
|
88
102
|
clearHandlers("sub");
|
|
@@ -152,7 +166,14 @@ function updateAppDbWithPatches(newDb, patches) {
|
|
|
152
166
|
const pathSegments = patch.path;
|
|
153
167
|
if (pathSegments.length > 0) {
|
|
154
168
|
const rootKey = pathSegments[0];
|
|
155
|
-
|
|
169
|
+
if (typeof rootKey !== "string") {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const subId = getRootSubIdBySource(rootKey);
|
|
173
|
+
if (!subId) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
const subVectorKey = JSON.stringify([subId]);
|
|
156
177
|
const reaction = getReaction(subVectorKey);
|
|
157
178
|
if (reaction) {
|
|
158
179
|
if (!reaction.isRoot) {
|
|
@@ -181,6 +202,51 @@ function updateAppDbWithPatches(newDb, patches) {
|
|
|
181
202
|
|
|
182
203
|
// src/immer-utils.ts
|
|
183
204
|
import { isDraft, original as immerOriginal, current as immerCurrent, enableMapSet as immerEnableMapSet } from "immer";
|
|
205
|
+
|
|
206
|
+
// src/settings.ts
|
|
207
|
+
import isEqual from "fast-deep-equal";
|
|
208
|
+
var store = {
|
|
209
|
+
globalInterceptors: [],
|
|
210
|
+
globalEqualityCheck: isEqual
|
|
211
|
+
};
|
|
212
|
+
function replaceGlobalInterceptor(globalInterceptors, interceptor) {
|
|
213
|
+
return globalInterceptors.reduce((ret, existingInterceptor) => {
|
|
214
|
+
if (interceptor.id === existingInterceptor.id) {
|
|
215
|
+
return [...ret, interceptor];
|
|
216
|
+
} else {
|
|
217
|
+
return [...ret, existingInterceptor];
|
|
218
|
+
}
|
|
219
|
+
}, []);
|
|
220
|
+
}
|
|
221
|
+
function regGlobalInterceptor(interceptor) {
|
|
222
|
+
const { id } = interceptor;
|
|
223
|
+
const ids = store.globalInterceptors.map((i) => i.id);
|
|
224
|
+
if (ids.includes(id)) {
|
|
225
|
+
store.globalInterceptors = replaceGlobalInterceptor(store.globalInterceptors, interceptor);
|
|
226
|
+
} else {
|
|
227
|
+
store.globalInterceptors = [...store.globalInterceptors, interceptor];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function getGlobalInterceptors() {
|
|
231
|
+
return [...store.globalInterceptors];
|
|
232
|
+
}
|
|
233
|
+
function clearGlobalInterceptors(id) {
|
|
234
|
+
if (id === void 0) {
|
|
235
|
+
store.globalInterceptors = [];
|
|
236
|
+
} else {
|
|
237
|
+
store.globalInterceptors = store.globalInterceptors.filter((interceptor) => interceptor.id !== id);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function setGlobalEqualityCheck(equalityCheck) {
|
|
241
|
+
store.globalEqualityCheck = equalityCheck;
|
|
242
|
+
}
|
|
243
|
+
function getGlobalEqualityCheck() {
|
|
244
|
+
return store.globalEqualityCheck;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// src/immer-utils.ts
|
|
248
|
+
import isEqual2 from "fast-deep-equal";
|
|
249
|
+
import isEqualEs6 from "fast-deep-equal/es6/index.js";
|
|
184
250
|
function original(value) {
|
|
185
251
|
return isDraft(value) ? immerOriginal(value) : value;
|
|
186
252
|
}
|
|
@@ -189,6 +255,9 @@ function current(value) {
|
|
|
189
255
|
}
|
|
190
256
|
function enableMapSet() {
|
|
191
257
|
immerEnableMapSet();
|
|
258
|
+
if (getGlobalEqualityCheck() === isEqual2) {
|
|
259
|
+
setGlobalEqualityCheck(isEqualEs6);
|
|
260
|
+
}
|
|
192
261
|
}
|
|
193
262
|
|
|
194
263
|
// src/interceptor.ts
|
|
@@ -526,47 +595,6 @@ regEffect(DISPATCH, (value) => {
|
|
|
526
595
|
// src/events.ts
|
|
527
596
|
import { enablePatches, produceWithPatches } from "immer";
|
|
528
597
|
|
|
529
|
-
// src/settings.ts
|
|
530
|
-
import isEqual from "fast-deep-equal";
|
|
531
|
-
var store = {
|
|
532
|
-
globalInterceptors: [],
|
|
533
|
-
globalEqualityCheck: isEqual
|
|
534
|
-
};
|
|
535
|
-
function replaceGlobalInterceptor(globalInterceptors, interceptor) {
|
|
536
|
-
return globalInterceptors.reduce((ret, existingInterceptor) => {
|
|
537
|
-
if (interceptor.id === existingInterceptor.id) {
|
|
538
|
-
return [...ret, interceptor];
|
|
539
|
-
} else {
|
|
540
|
-
return [...ret, existingInterceptor];
|
|
541
|
-
}
|
|
542
|
-
}, []);
|
|
543
|
-
}
|
|
544
|
-
function regGlobalInterceptor(interceptor) {
|
|
545
|
-
const { id } = interceptor;
|
|
546
|
-
const ids = store.globalInterceptors.map((i) => i.id);
|
|
547
|
-
if (ids.includes(id)) {
|
|
548
|
-
store.globalInterceptors = replaceGlobalInterceptor(store.globalInterceptors, interceptor);
|
|
549
|
-
} else {
|
|
550
|
-
store.globalInterceptors = [...store.globalInterceptors, interceptor];
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
function getGlobalInterceptors() {
|
|
554
|
-
return [...store.globalInterceptors];
|
|
555
|
-
}
|
|
556
|
-
function clearGlobalInterceptors(id) {
|
|
557
|
-
if (id === void 0) {
|
|
558
|
-
store.globalInterceptors = [];
|
|
559
|
-
} else {
|
|
560
|
-
store.globalInterceptors = store.globalInterceptors.filter((interceptor) => interceptor.id !== id);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
function setGlobalEqualityCheck(equalityCheck) {
|
|
564
|
-
store.globalEqualityCheck = equalityCheck;
|
|
565
|
-
}
|
|
566
|
-
function getGlobalEqualityCheck() {
|
|
567
|
-
return store.globalEqualityCheck;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
598
|
// src/trace.ts
|
|
571
599
|
var nextId = 1;
|
|
572
600
|
var traces = [];
|
|
@@ -801,7 +829,7 @@ function defaultErrorHandler(originalError, reflexError) {
|
|
|
801
829
|
regEventErrorHandler(defaultErrorHandler);
|
|
802
830
|
|
|
803
831
|
// src/reaction.ts
|
|
804
|
-
import
|
|
832
|
+
import isEqual3 from "fast-deep-equal";
|
|
805
833
|
var Reaction = class _Reaction {
|
|
806
834
|
id = "";
|
|
807
835
|
computeFn;
|
|
@@ -818,7 +846,7 @@ var Reaction = class _Reaction {
|
|
|
818
846
|
constructor(computeFn, deps, equalityCheck) {
|
|
819
847
|
this.computeFn = computeFn;
|
|
820
848
|
this.deps = deps;
|
|
821
|
-
this.equalityCheck = equalityCheck ||
|
|
849
|
+
this.equalityCheck = equalityCheck || isEqual3;
|
|
822
850
|
}
|
|
823
851
|
static create(fn, deps, equalityCheck) {
|
|
824
852
|
return new _Reaction(fn, deps, equalityCheck);
|
|
@@ -887,7 +915,7 @@ var Reaction = class _Reaction {
|
|
|
887
915
|
const depValues = this.deps?.map((d) => d.getDepValue(notifyWatchers)) ?? [];
|
|
888
916
|
const values = depValues.map(([value]) => value);
|
|
889
917
|
const currentVersions = depValues.map(([, version]) => version);
|
|
890
|
-
const versionsChanged = !
|
|
918
|
+
const versionsChanged = !isEqual3(currentVersions, this.depsVersions);
|
|
891
919
|
if (this.value === void 0 || versionsChanged) {
|
|
892
920
|
let newVal = this.computeFn(...values);
|
|
893
921
|
changed = !this.equalityCheck(newVal, this.value);
|
|
@@ -1004,16 +1032,23 @@ var Reaction = class _Reaction {
|
|
|
1004
1032
|
// src/subs.ts
|
|
1005
1033
|
var KIND4 = "sub";
|
|
1006
1034
|
var KIND_DEPS = "subDeps";
|
|
1035
|
+
function registerRootSub(id, sourceKey) {
|
|
1036
|
+
const conflictingSubId = getRootSubIdBySource(sourceKey);
|
|
1037
|
+
if (conflictingSubId && conflictingSubId !== id) {
|
|
1038
|
+
consoleLog("error", `[reflex] Subscription with id '${id}' will be overridden. Root key '${sourceKey}' is already used by subscription '${conflictingSubId}'.`);
|
|
1039
|
+
}
|
|
1040
|
+
setRootSubSource(id, sourceKey);
|
|
1041
|
+
registerHandler(KIND4, id, () => getAppDb()[sourceKey]);
|
|
1042
|
+
registerHandler(KIND_DEPS, id, () => []);
|
|
1043
|
+
}
|
|
1007
1044
|
function regSub(id, computeFn, depsFn, config) {
|
|
1008
1045
|
if (hasHandler(KIND4, id)) {
|
|
1009
1046
|
consoleLog("warn", `[reflex] Overriding. Subscription '${id}' already registered.`);
|
|
1010
1047
|
}
|
|
1011
1048
|
if (!computeFn) {
|
|
1012
|
-
|
|
1013
|
-
registerHandler(KIND_DEPS, id, () => []);
|
|
1049
|
+
registerRootSub(id, id);
|
|
1014
1050
|
} else if (typeof computeFn === "string") {
|
|
1015
|
-
|
|
1016
|
-
registerHandler(KIND_DEPS, id, () => []);
|
|
1051
|
+
registerRootSub(id, computeFn);
|
|
1017
1052
|
} else {
|
|
1018
1053
|
if (!depsFn) {
|
|
1019
1054
|
consoleLog("error", `[reflex] Subscription '${id}' has computeFn but missing depsFn. Computed subscriptions must specify their dependencies.`);
|