mobx 6.3.2 → 6.3.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.
@@ -510,7 +510,8 @@ function shallowComparer(a, b) {
510
510
  }
511
511
 
512
512
  function defaultComparer(a, b) {
513
- return Object.is(a, b);
513
+ if (Object.is) return Object.is(a, b);
514
+ return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
514
515
  }
515
516
 
516
517
  var comparer = {
@@ -955,6 +956,10 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
955
956
  return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
956
957
  }
957
958
 
959
+ var OBSERVABLE = "observable";
960
+ var OBSERVABLE_REF = "observable.ref";
961
+ var OBSERVABLE_SHALLOW = "observable.shallow";
962
+ var OBSERVABLE_STRUCT = "observable.struct"; // Predefined bags of create observable options, to avoid allocating temporarily option objects
958
963
  // in the majority of cases
959
964
 
960
965
  var defaultCreateObservableOptions = {
@@ -967,14 +972,14 @@ Object.freeze(defaultCreateObservableOptions);
967
972
  function asCreateObservableOptions(thing) {
968
973
  return thing || defaultCreateObservableOptions;
969
974
  }
970
- var observableAnnotation = /*#__PURE__*/createObservableAnnotation("observable");
971
- var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation("observable.ref", {
975
+ var observableAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE);
976
+ var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_REF, {
972
977
  enhancer: referenceEnhancer
973
978
  });
974
- var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation("observable.shallow", {
979
+ var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_SHALLOW, {
975
980
  enhancer: shallowEnhancer
976
981
  });
977
- var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation("observable.struct", {
982
+ var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_STRUCT, {
978
983
  enhancer: refStructEnhancer
979
984
  });
980
985
  var observableDecoratorAnnotation = /*#__PURE__*/createDecoratorAnnotation(observableAnnotation);
@@ -1579,6 +1584,10 @@ var ComputedValue = /*#__PURE__*/function () {
1579
1584
  if (!this.keepAlive_) {
1580
1585
  clearObserving(this);
1581
1586
  this.value_ = undefined; // don't hold on to computed value!
1587
+
1588
+ if ( this.isTracing_ !== TraceMode.NONE) {
1589
+ console.log("[mobx.trace] Computed value '" + this.name_ + "' was suspended and it will recompute on the next access.");
1590
+ }
1582
1591
  }
1583
1592
  };
1584
1593
 
@@ -1611,16 +1620,12 @@ var ComputedValue = /*#__PURE__*/function () {
1611
1620
 
1612
1621
  _proto.warnAboutUntrackedRead_ = function warnAboutUntrackedRead_() {
1613
1622
 
1614
- if (this.requiresReaction_ === true) {
1615
- die("[mobx] Computed value " + this.name_ + " is read outside a reactive context");
1616
- }
1617
-
1618
1623
  if (this.isTracing_ !== TraceMode.NONE) {
1619
- console.log("[mobx.trace] '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute");
1624
+ console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
1620
1625
  }
1621
1626
 
1622
- if (globalState.computedRequiresReaction) {
1623
- console.warn("[mobx] Computed value " + this.name_ + " is being read outside a reactive context. Doing a full recompute");
1627
+ if (globalState.computedRequiresReaction || this.requiresReaction_) {
1628
+ console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
1624
1629
  }
1625
1630
  };
1626
1631
 
@@ -1753,7 +1758,7 @@ function checkIfStateModificationsAreAllowed(atom) {
1753
1758
  }
1754
1759
  function checkIfStateReadsAreAllowed(observable) {
1755
1760
  if ( !globalState.allowStateReads && globalState.observableRequiresReaction) {
1756
- console.warn("[mobx] Observable " + observable.name_ + " being read outside a reactive context");
1761
+ console.warn("[mobx] Observable '" + observable.name_ + "' being read outside a reactive context.");
1757
1762
  }
1758
1763
  }
1759
1764
  /**
@@ -1797,7 +1802,7 @@ function warnAboutDerivationWithoutDependencies(derivation) {
1797
1802
  if (derivation.observing_.length !== 0) return;
1798
1803
 
1799
1804
  if (globalState.reactionRequiresObservable || derivation.requiresObservable_) {
1800
- console.warn("[mobx] Derivation " + derivation.name_ + " is created/updated without reading any observable value");
1805
+ console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
1801
1806
  }
1802
1807
  }
1803
1808
  /**
@@ -3281,10 +3286,10 @@ function _when(predicate, effect, opts) {
3281
3286
  var timeoutHandle;
3282
3287
 
3283
3288
  if (typeof opts.timeout === "number") {
3289
+ var error = new Error("WHEN_TIMEOUT");
3284
3290
  timeoutHandle = setTimeout(function () {
3285
3291
  if (!disposer[$mobx].isDisposed_) {
3286
3292
  disposer();
3287
- var error = new Error("WHEN_TIMEOUT");
3288
3293
  if (opts.onError) opts.onError(error);else throw error;
3289
3294
  }
3290
3295
  }, opts.timeout);
@@ -5734,7 +5739,7 @@ function isAnnotation(thing) {
5734
5739
  * - utils/ Utility stuff.
5735
5740
  *
5736
5741
  */
5737
- ["Symbol", "Map", "Set", "Symbol"].forEach(function (m) {
5742
+ ["Symbol", "Map", "Set"].forEach(function (m) {
5738
5743
  var g = getGlobal();
5739
5744
 
5740
5745
  if (typeof g[m] === "undefined") {