mobx 6.3.4 → 6.3.8

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/mobx.esm.js CHANGED
@@ -1537,22 +1537,21 @@ var ComputedValue = /*#__PURE__*/function () {
1537
1537
  /* see #1208 */
1538
1538
  this.dependenciesState_ === IDerivationState_.NOT_TRACKING_;
1539
1539
  var newValue = this.computeValue_(true);
1540
-
1541
- if (process.env.NODE_ENV !== "production" && isSpyEnabled()) {
1542
- spyReport({
1543
- observableKind: "computed",
1544
- debugObjectName: this.name_,
1545
- object: this.scope_,
1546
- type: "update",
1547
- oldValue: this.value_,
1548
- newValue: newValue
1549
- });
1550
- }
1551
-
1552
1540
  var changed = wasSuspended || isCaughtException(oldValue) || isCaughtException(newValue) || !this.equals_(oldValue, newValue);
1553
1541
 
1554
1542
  if (changed) {
1555
1543
  this.value_ = newValue;
1544
+
1545
+ if (process.env.NODE_ENV !== "production" && isSpyEnabled()) {
1546
+ spyReport({
1547
+ observableKind: "computed",
1548
+ debugObjectName: this.name_,
1549
+ object: this.scope_,
1550
+ type: "update",
1551
+ oldValue: oldValue,
1552
+ newValue: newValue
1553
+ });
1554
+ }
1556
1555
  }
1557
1556
 
1558
1557
  return changed;
@@ -2662,8 +2661,7 @@ function reaction(expression, effect, opts) {
2662
2661
  var firstTime = true;
2663
2662
  var isScheduled = false;
2664
2663
  var value;
2665
- var oldValue = undefined; // only an issue with fireImmediately
2666
-
2664
+ var oldValue;
2667
2665
  var equals = opts.compareStructural ? comparer.structural : opts.equals || comparer["default"];
2668
2666
  var r = new Reaction(name, function () {
2669
2667
  if (firstTime || runSync) {
@@ -3337,7 +3335,7 @@ function whenPromise(predicate, opts) {
3337
3335
 
3338
3336
  cancel = function cancel() {
3339
3337
  disposer();
3340
- reject("WHEN_CANCELLED");
3338
+ reject(new Error("WHEN_CANCELLED"));
3341
3339
  };
3342
3340
  });
3343
3341
  res.cancel = cancel;
@@ -3468,7 +3466,11 @@ function makeObservable(target, annotations, options) {
3468
3466
  try {
3469
3467
  var _annotations;
3470
3468
 
3471
- // Default to decorators
3469
+ if (process.env.NODE_ENV !== "production" && annotations && target[storedAnnotationsSymbol]) {
3470
+ die("makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported.");
3471
+ } // Default to decorators
3472
+
3473
+
3472
3474
  (_annotations = annotations) != null ? _annotations : annotations = collectStoredAnnotations(target); // Annotate
3473
3475
 
3474
3476
  ownKeys(annotations).forEach(function (key) {
@@ -3691,9 +3693,12 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3691
3693
 
3692
3694
  return (_this$values_ = this.values_).splice.apply(_this$values_, [index, deleteCount].concat(newItems));
3693
3695
  } else {
3694
- var res = this.values_.slice(index, index + deleteCount);
3695
- var oldItems = this.values_.slice(index + deleteCount);
3696
- this.values_.length = index + newItems.length - deleteCount;
3696
+ // The items removed by the splice
3697
+ var res = this.values_.slice(index, index + deleteCount); // The items that that should remain at the end of the array
3698
+
3699
+ var oldItems = this.values_.slice(index + deleteCount); // New length is the previous length + addition count - deletion count
3700
+
3701
+ this.values_.length += newItems.length - deleteCount;
3697
3702
 
3698
3703
  for (var i = 0; i < newItems.length; i++) {
3699
3704
  this.values_[index + i] = newItems[i];