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.
- package/CHANGELOG.md +17 -0
- package/README.md +3 -3
- package/dist/api/autorun.d.ts +3 -3
- package/dist/mobx.cjs.development.js +21 -16
- package/dist/mobx.cjs.development.js.map +1 -1
- package/dist/mobx.cjs.production.min.js +1 -1
- package/dist/mobx.cjs.production.min.js.map +1 -1
- package/dist/mobx.esm.development.js +21 -16
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +21 -16
- package/dist/mobx.esm.js.map +1 -1
- package/dist/mobx.esm.production.min.js +1 -1
- package/dist/mobx.esm.production.min.js.map +1 -1
- package/dist/mobx.umd.development.js +21 -16
- package/dist/mobx.umd.development.js.map +1 -1
- package/dist/mobx.umd.production.min.js +1 -1
- package/dist/mobx.umd.production.min.js.map +1 -1
- package/package.json +1 -1
- package/src/api/autorun.ts +5 -5
- package/src/api/observable.ts +4 -4
- package/src/api/when.ts +1 -1
- package/src/core/computedvalue.ts +8 -6
- package/src/core/derivation.ts +4 -2
- package/src/mobx.ts +1 -1
- package/src/utils/comparer.ts +5 -1
|
@@ -516,7 +516,8 @@
|
|
|
516
516
|
}
|
|
517
517
|
|
|
518
518
|
function defaultComparer(a, b) {
|
|
519
|
-
return Object.is(a, b);
|
|
519
|
+
if (Object.is) return Object.is(a, b);
|
|
520
|
+
return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
|
|
520
521
|
}
|
|
521
522
|
|
|
522
523
|
var comparer = {
|
|
@@ -961,6 +962,10 @@
|
|
|
961
962
|
return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
|
|
962
963
|
}
|
|
963
964
|
|
|
965
|
+
var OBSERVABLE = "observable";
|
|
966
|
+
var OBSERVABLE_REF = "observable.ref";
|
|
967
|
+
var OBSERVABLE_SHALLOW = "observable.shallow";
|
|
968
|
+
var OBSERVABLE_STRUCT = "observable.struct"; // Predefined bags of create observable options, to avoid allocating temporarily option objects
|
|
964
969
|
// in the majority of cases
|
|
965
970
|
|
|
966
971
|
var defaultCreateObservableOptions = {
|
|
@@ -973,14 +978,14 @@
|
|
|
973
978
|
function asCreateObservableOptions(thing) {
|
|
974
979
|
return thing || defaultCreateObservableOptions;
|
|
975
980
|
}
|
|
976
|
-
var observableAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
977
|
-
var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
981
|
+
var observableAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE);
|
|
982
|
+
var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_REF, {
|
|
978
983
|
enhancer: referenceEnhancer
|
|
979
984
|
});
|
|
980
|
-
var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
985
|
+
var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_SHALLOW, {
|
|
981
986
|
enhancer: shallowEnhancer
|
|
982
987
|
});
|
|
983
|
-
var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
988
|
+
var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_STRUCT, {
|
|
984
989
|
enhancer: refStructEnhancer
|
|
985
990
|
});
|
|
986
991
|
var observableDecoratorAnnotation = /*#__PURE__*/createDecoratorAnnotation(observableAnnotation);
|
|
@@ -1585,6 +1590,10 @@
|
|
|
1585
1590
|
if (!this.keepAlive_) {
|
|
1586
1591
|
clearObserving(this);
|
|
1587
1592
|
this.value_ = undefined; // don't hold on to computed value!
|
|
1593
|
+
|
|
1594
|
+
if ( this.isTracing_ !== TraceMode.NONE) {
|
|
1595
|
+
console.log("[mobx.trace] Computed value '" + this.name_ + "' was suspended and it will recompute on the next access.");
|
|
1596
|
+
}
|
|
1588
1597
|
}
|
|
1589
1598
|
};
|
|
1590
1599
|
|
|
@@ -1617,16 +1626,12 @@
|
|
|
1617
1626
|
|
|
1618
1627
|
_proto.warnAboutUntrackedRead_ = function warnAboutUntrackedRead_() {
|
|
1619
1628
|
|
|
1620
|
-
if (this.requiresReaction_ === true) {
|
|
1621
|
-
die("[mobx] Computed value " + this.name_ + " is read outside a reactive context");
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
1629
|
if (this.isTracing_ !== TraceMode.NONE) {
|
|
1625
|
-
console.log("[mobx.trace] '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute");
|
|
1630
|
+
console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1626
1631
|
}
|
|
1627
1632
|
|
|
1628
|
-
if (globalState.computedRequiresReaction) {
|
|
1629
|
-
console.warn("[mobx] Computed value " + this.name_ + " is being read outside a reactive context. Doing a full recompute");
|
|
1633
|
+
if (globalState.computedRequiresReaction || this.requiresReaction_) {
|
|
1634
|
+
console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1630
1635
|
}
|
|
1631
1636
|
};
|
|
1632
1637
|
|
|
@@ -1759,7 +1764,7 @@
|
|
|
1759
1764
|
}
|
|
1760
1765
|
function checkIfStateReadsAreAllowed(observable) {
|
|
1761
1766
|
if ( !globalState.allowStateReads && globalState.observableRequiresReaction) {
|
|
1762
|
-
console.warn("[mobx] Observable " + observable.name_ + " being read outside a reactive context");
|
|
1767
|
+
console.warn("[mobx] Observable '" + observable.name_ + "' being read outside a reactive context.");
|
|
1763
1768
|
}
|
|
1764
1769
|
}
|
|
1765
1770
|
/**
|
|
@@ -1803,7 +1808,7 @@
|
|
|
1803
1808
|
if (derivation.observing_.length !== 0) return;
|
|
1804
1809
|
|
|
1805
1810
|
if (globalState.reactionRequiresObservable || derivation.requiresObservable_) {
|
|
1806
|
-
console.warn("[mobx] Derivation " + derivation.name_ + " is created/updated without reading any observable value");
|
|
1811
|
+
console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
|
|
1807
1812
|
}
|
|
1808
1813
|
}
|
|
1809
1814
|
/**
|
|
@@ -3287,10 +3292,10 @@
|
|
|
3287
3292
|
var timeoutHandle;
|
|
3288
3293
|
|
|
3289
3294
|
if (typeof opts.timeout === "number") {
|
|
3295
|
+
var error = new Error("WHEN_TIMEOUT");
|
|
3290
3296
|
timeoutHandle = setTimeout(function () {
|
|
3291
3297
|
if (!disposer[$mobx].isDisposed_) {
|
|
3292
3298
|
disposer();
|
|
3293
|
-
var error = new Error("WHEN_TIMEOUT");
|
|
3294
3299
|
if (opts.onError) opts.onError(error);else throw error;
|
|
3295
3300
|
}
|
|
3296
3301
|
}, opts.timeout);
|
|
@@ -5740,7 +5745,7 @@
|
|
|
5740
5745
|
* - utils/ Utility stuff.
|
|
5741
5746
|
*
|
|
5742
5747
|
*/
|
|
5743
|
-
["Symbol", "Map", "Set"
|
|
5748
|
+
["Symbol", "Map", "Set"].forEach(function (m) {
|
|
5744
5749
|
var g = getGlobal();
|
|
5745
5750
|
|
|
5746
5751
|
if (typeof g[m] === "undefined") {
|