@manyducks.co/dolla 0.77.1 → 0.77.3
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/lib/index.js +16 -1
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -508,12 +508,27 @@ function computed(...args) {
|
|
|
508
508
|
let observedValues = [];
|
|
509
509
|
let valuesChanged = [];
|
|
510
510
|
let latestComputedValue = UNOBSERVED;
|
|
511
|
+
let computedStopCallback;
|
|
511
512
|
function updateValue() {
|
|
512
513
|
if (!valuesChanged.some((x) => x)) {
|
|
513
514
|
return;
|
|
514
515
|
}
|
|
515
516
|
const computedValue = compute(...observedValues);
|
|
516
|
-
if (
|
|
517
|
+
if (isReadable(computedValue)) {
|
|
518
|
+
if (computedStopCallback) {
|
|
519
|
+
computedStopCallback();
|
|
520
|
+
}
|
|
521
|
+
computedStopCallback = computedValue[OBSERVE]((current) => {
|
|
522
|
+
latestComputedValue = current;
|
|
523
|
+
for (const callback of observers) {
|
|
524
|
+
callback(current);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
} else if (!deepEqual(computedValue, latestComputedValue)) {
|
|
528
|
+
if (computedStopCallback) {
|
|
529
|
+
computedStopCallback();
|
|
530
|
+
computedStopCallback = void 0;
|
|
531
|
+
}
|
|
517
532
|
latestComputedValue = computedValue;
|
|
518
533
|
for (const callback of observers) {
|
|
519
534
|
callback(computedValue);
|