@manyducks.co/dolla 0.77.1 → 0.77.2

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 CHANGED
@@ -508,12 +508,28 @@ 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 (!deepEqual(computedValue, latestComputedValue)) {
517
+ if (isReadable(computedValue)) {
518
+ if (computedStopCallback) {
519
+ computedStopCallback();
520
+ }
521
+ latestComputedValue = computedValue;
522
+ computedStopCallback = computedValue[OBSERVE]((current) => {
523
+ latestComputedValue = current;
524
+ for (const callback of observers) {
525
+ callback(computedValue);
526
+ }
527
+ });
528
+ } else if (!deepEqual(computedValue, latestComputedValue)) {
529
+ if (computedStopCallback) {
530
+ computedStopCallback();
531
+ computedStopCallback = void 0;
532
+ }
517
533
  latestComputedValue = computedValue;
518
534
  for (const callback of observers) {
519
535
  callback(computedValue);
@@ -556,10 +572,16 @@ function computed(...args) {
556
572
  }
557
573
  return {
558
574
  get: () => {
575
+ let computed2;
559
576
  if (isObserving) {
560
- return latestComputedValue;
577
+ computed2 = latestComputedValue;
578
+ } else {
579
+ computed2 = compute(...readables.map((x) => x.get()));
580
+ }
581
+ if (isReadable(computed2)) {
582
+ return computed2.get();
561
583
  } else {
562
- return compute(...readables.map((x) => x.get()));
584
+ return computed2;
563
585
  }
564
586
  },
565
587
  [OBSERVE]: (callback) => {