@esportsplus/reactivity 0.16.0 → 0.16.1
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/build/system.js +12 -3
- package/package.json +1 -1
- package/src/system.ts +16 -4
package/build/system.js
CHANGED
|
@@ -332,14 +332,23 @@ const read = (node) => {
|
|
|
332
332
|
return node.value;
|
|
333
333
|
};
|
|
334
334
|
const root = (fn) => {
|
|
335
|
-
let d = root.disposables, o = observer, s = scope, self = null, tracking = fn.length;
|
|
335
|
+
let c, d = root.disposables, o = observer, s = scope, self = null, tracking = fn.length, value;
|
|
336
336
|
observer = null;
|
|
337
337
|
root.disposables = 0;
|
|
338
|
-
|
|
339
|
-
|
|
338
|
+
if (tracking) {
|
|
339
|
+
scope = self = { cleanup: null };
|
|
340
|
+
value = fn(c = () => dispose(self));
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
scope = null;
|
|
344
|
+
value = fn();
|
|
345
|
+
}
|
|
340
346
|
observer = o;
|
|
341
347
|
root.disposables = d;
|
|
342
348
|
scope = s;
|
|
349
|
+
if (c) {
|
|
350
|
+
onCleanup(c);
|
|
351
|
+
}
|
|
343
352
|
return value;
|
|
344
353
|
};
|
|
345
354
|
root.disposables = 0;
|
package/package.json
CHANGED
package/src/system.ts
CHANGED
|
@@ -465,22 +465,34 @@ const read = <T>(node: Signal<T> | Computed<T>): T => {
|
|
|
465
465
|
};
|
|
466
466
|
|
|
467
467
|
const root = <T>(fn: (dispose?: VoidFunction) => T) => {
|
|
468
|
-
let
|
|
468
|
+
let c,
|
|
469
|
+
d = root.disposables,
|
|
469
470
|
o = observer,
|
|
470
471
|
s = scope,
|
|
471
472
|
self: Computed<unknown> | null = null,
|
|
472
|
-
tracking = fn.length
|
|
473
|
+
tracking = fn.length,
|
|
474
|
+
value: T;
|
|
473
475
|
|
|
474
476
|
observer = null;
|
|
475
477
|
root.disposables = 0;
|
|
476
|
-
scope = tracking ? (self = { cleanup: null } as Computed<unknown>) : null;
|
|
477
478
|
|
|
478
|
-
|
|
479
|
+
if (tracking) {
|
|
480
|
+
scope = self = { cleanup: null } as Computed<unknown>;
|
|
481
|
+
value = fn( c = () => dispose(self!) );
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
scope = null;
|
|
485
|
+
value = fn();
|
|
486
|
+
}
|
|
479
487
|
|
|
480
488
|
observer = o;
|
|
481
489
|
root.disposables = d;
|
|
482
490
|
scope = s;
|
|
483
491
|
|
|
492
|
+
if (c) {
|
|
493
|
+
onCleanup(c);
|
|
494
|
+
}
|
|
495
|
+
|
|
484
496
|
return value;
|
|
485
497
|
};
|
|
486
498
|
|