mobx 6.11.0 → 6.12.1
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 +18 -0
- package/README.md +27 -31
- package/dist/core/atom.d.ts +0 -1
- package/dist/core/globalstate.d.ts +0 -9
- package/dist/mobx.cjs.development.js +19 -22
- 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 +19 -22
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +19 -22
- 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 +19 -22
- 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 +2 -3
- package/src/core/action.ts +1 -0
- package/src/core/atom.ts +2 -17
- package/src/core/derivation.ts +6 -3
- package/src/core/globalstate.ts +0 -11
- package/src/core/observable.ts +0 -6
- package/src/types/legacyobservablearray.ts +1 -1
- package/src/types/observablearray.ts +9 -2
|
@@ -436,14 +436,12 @@ var Atom = /*#__PURE__*/function () {
|
|
|
436
436
|
this.isPendingUnobservation_ = false;
|
|
437
437
|
this.isBeingObserved_ = false;
|
|
438
438
|
this.observers_ = new Set();
|
|
439
|
-
this.batchId_ = void 0;
|
|
440
439
|
this.diffValue_ = 0;
|
|
441
440
|
this.lastAccessedBy_ = 0;
|
|
442
441
|
this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_;
|
|
443
442
|
this.onBOL = void 0;
|
|
444
443
|
this.onBUOL = void 0;
|
|
445
444
|
this.name_ = name_;
|
|
446
|
-
this.batchId_ = globalState.inBatch ? globalState.batchId : NaN;
|
|
447
445
|
}
|
|
448
446
|
// onBecomeObservedListeners
|
|
449
447
|
var _proto = Atom.prototype;
|
|
@@ -472,13 +470,6 @@ var Atom = /*#__PURE__*/function () {
|
|
|
472
470
|
* Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
|
|
473
471
|
*/;
|
|
474
472
|
_proto.reportChanged = function reportChanged() {
|
|
475
|
-
if (!globalState.inBatch || this.batchId_ !== globalState.batchId) {
|
|
476
|
-
// We could update state version only at the end of batch,
|
|
477
|
-
// but we would still have to switch some global flag here to signal a change.
|
|
478
|
-
globalState.stateVersion = globalState.stateVersion < Number.MAX_SAFE_INTEGER ? globalState.stateVersion + 1 : Number.MIN_SAFE_INTEGER;
|
|
479
|
-
// Avoids the possibility of hitting the same globalState.batchId when it cycled through all integers (necessary?)
|
|
480
|
-
this.batchId_ = NaN;
|
|
481
|
-
}
|
|
482
473
|
startBatch();
|
|
483
474
|
propagateChanged(this);
|
|
484
475
|
endBatch();
|
|
@@ -1231,6 +1222,9 @@ function createAction(actionName, fn, autoAction, ref) {
|
|
|
1231
1222
|
return executeAction(actionName, autoAction, fn, ref || this, arguments);
|
|
1232
1223
|
}
|
|
1233
1224
|
res.isMobxAction = true;
|
|
1225
|
+
res.toString = function () {
|
|
1226
|
+
return fn.toString();
|
|
1227
|
+
};
|
|
1234
1228
|
if (isFunctionNameConfigurable) {
|
|
1235
1229
|
tmpNameDescriptor.value = actionName;
|
|
1236
1230
|
defineProperty(res, "name", tmpNameDescriptor);
|
|
@@ -1822,10 +1816,12 @@ function checkIfStateReadsAreAllowed(observable) {
|
|
|
1822
1816
|
*/
|
|
1823
1817
|
function trackDerivedFunction(derivation, f, context) {
|
|
1824
1818
|
var prevAllowStateReads = allowStateReadsStart(true);
|
|
1825
|
-
// pre allocate array allocation + room for variation in deps
|
|
1826
|
-
// array will be trimmed by bindDependencies
|
|
1827
1819
|
changeDependenciesStateTo0(derivation);
|
|
1828
|
-
|
|
1820
|
+
// Preallocate array; will be trimmed by bindDependencies.
|
|
1821
|
+
derivation.newObserving_ = new Array(
|
|
1822
|
+
// Reserve constant space for initial dependencies, dynamic space otherwise.
|
|
1823
|
+
// See https://github.com/mobxjs/mobx/pull/3833
|
|
1824
|
+
derivation.runId_ === 0 ? 100 : derivation.observing_.length);
|
|
1829
1825
|
derivation.unboundDepsCount_ = 0;
|
|
1830
1826
|
derivation.runId_ = ++globalState.runId;
|
|
1831
1827
|
var prevTracking = globalState.trackingDerivation;
|
|
@@ -1978,7 +1974,6 @@ var MobXGlobals = function MobXGlobals() {
|
|
|
1978
1974
|
this.runId = 0;
|
|
1979
1975
|
this.mobxGuid = 0;
|
|
1980
1976
|
this.inBatch = 0;
|
|
1981
|
-
this.batchId = Number.MIN_SAFE_INTEGER;
|
|
1982
1977
|
this.pendingUnobservations = [];
|
|
1983
1978
|
this.pendingReactions = [];
|
|
1984
1979
|
this.isRunningReactions = false;
|
|
@@ -1995,7 +1990,6 @@ var MobXGlobals = function MobXGlobals() {
|
|
|
1995
1990
|
this.useProxies = true;
|
|
1996
1991
|
this.verifyProxies = false;
|
|
1997
1992
|
this.safeDescriptors = true;
|
|
1998
|
-
this.stateVersion = Number.MIN_SAFE_INTEGER;
|
|
1999
1993
|
};
|
|
2000
1994
|
var canMergeGlobalState = true;
|
|
2001
1995
|
var isolateCalled = false;
|
|
@@ -2118,9 +2112,6 @@ function queueForUnobservation(observable) {
|
|
|
2118
2112
|
* Avoids unnecessary recalculations.
|
|
2119
2113
|
*/
|
|
2120
2114
|
function startBatch() {
|
|
2121
|
-
if (globalState.inBatch === 0) {
|
|
2122
|
-
globalState.batchId = globalState.batchId < Number.MAX_SAFE_INTEGER ? globalState.batchId + 1 : Number.MIN_SAFE_INTEGER;
|
|
2123
|
-
}
|
|
2124
2115
|
globalState.inBatch++;
|
|
2125
2116
|
}
|
|
2126
2117
|
function endBatch() {
|
|
@@ -2671,7 +2662,6 @@ function reaction(expression, effect, opts) {
|
|
|
2671
2662
|
var firstTime = true;
|
|
2672
2663
|
var isScheduled = false;
|
|
2673
2664
|
var value;
|
|
2674
|
-
var oldValue;
|
|
2675
2665
|
var equals = opts.compareStructural ? comparer.structural : opts.equals || comparer["default"];
|
|
2676
2666
|
var r = new Reaction(name, function () {
|
|
2677
2667
|
if (firstTime || runSync) {
|
|
@@ -2687,12 +2677,12 @@ function reaction(expression, effect, opts) {
|
|
|
2687
2677
|
return;
|
|
2688
2678
|
}
|
|
2689
2679
|
var changed = false;
|
|
2680
|
+
var oldValue = value;
|
|
2690
2681
|
r.track(function () {
|
|
2691
2682
|
var nextValue = allowStateChanges(false, function () {
|
|
2692
2683
|
return expression(r);
|
|
2693
2684
|
});
|
|
2694
2685
|
changed = firstTime || !equals(value, nextValue);
|
|
2695
|
-
oldValue = value;
|
|
2696
2686
|
value = nextValue;
|
|
2697
2687
|
});
|
|
2698
2688
|
if (firstTime && opts.fireImmediately) {
|
|
@@ -3957,6 +3947,7 @@ var arrayExtensions = {
|
|
|
3957
3947
|
* Without this, everything works as well, but this works
|
|
3958
3948
|
* faster as everything works on unproxied values
|
|
3959
3949
|
*/
|
|
3950
|
+
addArrayExtension("at", simpleFunc);
|
|
3960
3951
|
addArrayExtension("concat", simpleFunc);
|
|
3961
3952
|
addArrayExtension("flat", simpleFunc);
|
|
3962
3953
|
addArrayExtension("includes", simpleFunc);
|
|
@@ -3966,15 +3957,21 @@ addArrayExtension("lastIndexOf", simpleFunc);
|
|
|
3966
3957
|
addArrayExtension("slice", simpleFunc);
|
|
3967
3958
|
addArrayExtension("toString", simpleFunc);
|
|
3968
3959
|
addArrayExtension("toLocaleString", simpleFunc);
|
|
3960
|
+
addArrayExtension("toSorted", simpleFunc);
|
|
3961
|
+
addArrayExtension("toSpliced", simpleFunc);
|
|
3962
|
+
addArrayExtension("with", simpleFunc);
|
|
3969
3963
|
// map
|
|
3970
3964
|
addArrayExtension("every", mapLikeFunc);
|
|
3971
3965
|
addArrayExtension("filter", mapLikeFunc);
|
|
3972
3966
|
addArrayExtension("find", mapLikeFunc);
|
|
3973
3967
|
addArrayExtension("findIndex", mapLikeFunc);
|
|
3968
|
+
addArrayExtension("findLast", mapLikeFunc);
|
|
3969
|
+
addArrayExtension("findLastIndex", mapLikeFunc);
|
|
3974
3970
|
addArrayExtension("flatMap", mapLikeFunc);
|
|
3975
3971
|
addArrayExtension("forEach", mapLikeFunc);
|
|
3976
3972
|
addArrayExtension("map", mapLikeFunc);
|
|
3977
3973
|
addArrayExtension("some", mapLikeFunc);
|
|
3974
|
+
addArrayExtension("toReversed", mapLikeFunc);
|
|
3978
3975
|
// reduce
|
|
3979
3976
|
addArrayExtension("reduce", reduceLikeFunc);
|
|
3980
3977
|
addArrayExtension("reduceRight", reduceLikeFunc);
|
|
@@ -3992,7 +3989,7 @@ function simpleFunc(funcName) {
|
|
|
3992
3989
|
return dehancedValues[funcName].apply(dehancedValues, arguments);
|
|
3993
3990
|
};
|
|
3994
3991
|
}
|
|
3995
|
-
// Make sure callbacks
|
|
3992
|
+
// Make sure callbacks receive correct array arg #2326
|
|
3996
3993
|
function mapLikeFunc(funcName) {
|
|
3997
3994
|
return function (callback, thisArg) {
|
|
3998
3995
|
var _this2 = this;
|
|
@@ -4004,7 +4001,7 @@ function mapLikeFunc(funcName) {
|
|
|
4004
4001
|
});
|
|
4005
4002
|
};
|
|
4006
4003
|
}
|
|
4007
|
-
// Make sure callbacks
|
|
4004
|
+
// Make sure callbacks receive correct array arg #2326
|
|
4008
4005
|
function reduceLikeFunc(funcName) {
|
|
4009
4006
|
return function () {
|
|
4010
4007
|
var _this3 = this;
|
|
@@ -5337,7 +5334,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5337
5334
|
_this.spliceWithArray(0, 0, initialValues);
|
|
5338
5335
|
}
|
|
5339
5336
|
if (safariPrototypeSetterInheritanceBug) {
|
|
5340
|
-
// Seems that Safari won't use numeric prototype setter
|
|
5337
|
+
// Seems that Safari won't use numeric prototype setter until any * numeric property is
|
|
5341
5338
|
// defined on the instance. After that it works fine, even if this property is deleted.
|
|
5342
5339
|
Object.defineProperty(_assertThisInitialized(_this), "0", ENTRY_0);
|
|
5343
5340
|
}
|