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
package/dist/mobx.esm.js
CHANGED
|
@@ -512,7 +512,8 @@ function shallowComparer(a, b) {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
function defaultComparer(a, b) {
|
|
515
|
-
return Object.is(a, b);
|
|
515
|
+
if (Object.is) return Object.is(a, b);
|
|
516
|
+
return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
|
|
516
517
|
}
|
|
517
518
|
|
|
518
519
|
var comparer = {
|
|
@@ -957,6 +958,10 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
|
957
958
|
return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
|
|
958
959
|
}
|
|
959
960
|
|
|
961
|
+
var OBSERVABLE = "observable";
|
|
962
|
+
var OBSERVABLE_REF = "observable.ref";
|
|
963
|
+
var OBSERVABLE_SHALLOW = "observable.shallow";
|
|
964
|
+
var OBSERVABLE_STRUCT = "observable.struct"; // Predefined bags of create observable options, to avoid allocating temporarily option objects
|
|
960
965
|
// in the majority of cases
|
|
961
966
|
|
|
962
967
|
var defaultCreateObservableOptions = {
|
|
@@ -969,14 +974,14 @@ Object.freeze(defaultCreateObservableOptions);
|
|
|
969
974
|
function asCreateObservableOptions(thing) {
|
|
970
975
|
return thing || defaultCreateObservableOptions;
|
|
971
976
|
}
|
|
972
|
-
var observableAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
973
|
-
var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
977
|
+
var observableAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE);
|
|
978
|
+
var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_REF, {
|
|
974
979
|
enhancer: referenceEnhancer
|
|
975
980
|
});
|
|
976
|
-
var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
981
|
+
var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_SHALLOW, {
|
|
977
982
|
enhancer: shallowEnhancer
|
|
978
983
|
});
|
|
979
|
-
var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
984
|
+
var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_STRUCT, {
|
|
980
985
|
enhancer: refStructEnhancer
|
|
981
986
|
});
|
|
982
987
|
var observableDecoratorAnnotation = /*#__PURE__*/createDecoratorAnnotation(observableAnnotation);
|
|
@@ -1581,6 +1586,10 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1581
1586
|
if (!this.keepAlive_) {
|
|
1582
1587
|
clearObserving(this);
|
|
1583
1588
|
this.value_ = undefined; // don't hold on to computed value!
|
|
1589
|
+
|
|
1590
|
+
if (process.env.NODE_ENV !== "production" && this.isTracing_ !== TraceMode.NONE) {
|
|
1591
|
+
console.log("[mobx.trace] Computed value '" + this.name_ + "' was suspended and it will recompute on the next access.");
|
|
1592
|
+
}
|
|
1584
1593
|
}
|
|
1585
1594
|
};
|
|
1586
1595
|
|
|
@@ -1614,16 +1623,12 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1614
1623
|
_proto.warnAboutUntrackedRead_ = function warnAboutUntrackedRead_() {
|
|
1615
1624
|
if (!(process.env.NODE_ENV !== "production")) return;
|
|
1616
1625
|
|
|
1617
|
-
if (this.requiresReaction_ === true) {
|
|
1618
|
-
die("[mobx] Computed value " + this.name_ + " is read outside a reactive context");
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
1626
|
if (this.isTracing_ !== TraceMode.NONE) {
|
|
1622
|
-
console.log("[mobx.trace] '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute");
|
|
1627
|
+
console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1623
1628
|
}
|
|
1624
1629
|
|
|
1625
|
-
if (globalState.computedRequiresReaction) {
|
|
1626
|
-
console.warn("[mobx] Computed value " + this.name_ + " is being read outside a reactive context. Doing a full recompute");
|
|
1630
|
+
if (globalState.computedRequiresReaction || this.requiresReaction_) {
|
|
1631
|
+
console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1627
1632
|
}
|
|
1628
1633
|
};
|
|
1629
1634
|
|
|
@@ -1759,7 +1764,7 @@ function checkIfStateModificationsAreAllowed(atom) {
|
|
|
1759
1764
|
}
|
|
1760
1765
|
function checkIfStateReadsAreAllowed(observable) {
|
|
1761
1766
|
if (process.env.NODE_ENV !== "production" && !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
|
/**
|
|
@@ -1804,7 +1809,7 @@ function warnAboutDerivationWithoutDependencies(derivation) {
|
|
|
1804
1809
|
if (derivation.observing_.length !== 0) return;
|
|
1805
1810
|
|
|
1806
1811
|
if (globalState.reactionRequiresObservable || derivation.requiresObservable_) {
|
|
1807
|
-
console.warn("[mobx] Derivation " + derivation.name_ + " is created/updated without reading any observable value");
|
|
1812
|
+
console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
|
|
1808
1813
|
}
|
|
1809
1814
|
}
|
|
1810
1815
|
/**
|
|
@@ -3295,10 +3300,10 @@ function _when(predicate, effect, opts) {
|
|
|
3295
3300
|
var timeoutHandle;
|
|
3296
3301
|
|
|
3297
3302
|
if (typeof opts.timeout === "number") {
|
|
3303
|
+
var error = new Error("WHEN_TIMEOUT");
|
|
3298
3304
|
timeoutHandle = setTimeout(function () {
|
|
3299
3305
|
if (!disposer[$mobx].isDisposed_) {
|
|
3300
3306
|
disposer();
|
|
3301
|
-
var error = new Error("WHEN_TIMEOUT");
|
|
3302
3307
|
if (opts.onError) opts.onError(error);else throw error;
|
|
3303
3308
|
}
|
|
3304
3309
|
}, opts.timeout);
|
|
@@ -5748,7 +5753,7 @@ function isAnnotation(thing) {
|
|
|
5748
5753
|
* - utils/ Utility stuff.
|
|
5749
5754
|
*
|
|
5750
5755
|
*/
|
|
5751
|
-
["Symbol", "Map", "Set"
|
|
5756
|
+
["Symbol", "Map", "Set"].forEach(function (m) {
|
|
5752
5757
|
var g = getGlobal();
|
|
5753
5758
|
|
|
5754
5759
|
if (typeof g[m] === "undefined") {
|