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
|
@@ -442,14 +442,12 @@
|
|
|
442
442
|
this.isPendingUnobservation_ = false;
|
|
443
443
|
this.isBeingObserved_ = false;
|
|
444
444
|
this.observers_ = new Set();
|
|
445
|
-
this.batchId_ = void 0;
|
|
446
445
|
this.diffValue_ = 0;
|
|
447
446
|
this.lastAccessedBy_ = 0;
|
|
448
447
|
this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_;
|
|
449
448
|
this.onBOL = void 0;
|
|
450
449
|
this.onBUOL = void 0;
|
|
451
450
|
this.name_ = name_;
|
|
452
|
-
this.batchId_ = globalState.inBatch ? globalState.batchId : NaN;
|
|
453
451
|
}
|
|
454
452
|
// onBecomeObservedListeners
|
|
455
453
|
var _proto = Atom.prototype;
|
|
@@ -478,13 +476,6 @@
|
|
|
478
476
|
* Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
|
|
479
477
|
*/;
|
|
480
478
|
_proto.reportChanged = function reportChanged() {
|
|
481
|
-
if (!globalState.inBatch || this.batchId_ !== globalState.batchId) {
|
|
482
|
-
// We could update state version only at the end of batch,
|
|
483
|
-
// but we would still have to switch some global flag here to signal a change.
|
|
484
|
-
globalState.stateVersion = globalState.stateVersion < Number.MAX_SAFE_INTEGER ? globalState.stateVersion + 1 : Number.MIN_SAFE_INTEGER;
|
|
485
|
-
// Avoids the possibility of hitting the same globalState.batchId when it cycled through all integers (necessary?)
|
|
486
|
-
this.batchId_ = NaN;
|
|
487
|
-
}
|
|
488
479
|
startBatch();
|
|
489
480
|
propagateChanged(this);
|
|
490
481
|
endBatch();
|
|
@@ -1237,6 +1228,9 @@
|
|
|
1237
1228
|
return executeAction(actionName, autoAction, fn, ref || this, arguments);
|
|
1238
1229
|
}
|
|
1239
1230
|
res.isMobxAction = true;
|
|
1231
|
+
res.toString = function () {
|
|
1232
|
+
return fn.toString();
|
|
1233
|
+
};
|
|
1240
1234
|
if (isFunctionNameConfigurable) {
|
|
1241
1235
|
tmpNameDescriptor.value = actionName;
|
|
1242
1236
|
defineProperty(res, "name", tmpNameDescriptor);
|
|
@@ -1828,10 +1822,12 @@
|
|
|
1828
1822
|
*/
|
|
1829
1823
|
function trackDerivedFunction(derivation, f, context) {
|
|
1830
1824
|
var prevAllowStateReads = allowStateReadsStart(true);
|
|
1831
|
-
// pre allocate array allocation + room for variation in deps
|
|
1832
|
-
// array will be trimmed by bindDependencies
|
|
1833
1825
|
changeDependenciesStateTo0(derivation);
|
|
1834
|
-
|
|
1826
|
+
// Preallocate array; will be trimmed by bindDependencies.
|
|
1827
|
+
derivation.newObserving_ = new Array(
|
|
1828
|
+
// Reserve constant space for initial dependencies, dynamic space otherwise.
|
|
1829
|
+
// See https://github.com/mobxjs/mobx/pull/3833
|
|
1830
|
+
derivation.runId_ === 0 ? 100 : derivation.observing_.length);
|
|
1835
1831
|
derivation.unboundDepsCount_ = 0;
|
|
1836
1832
|
derivation.runId_ = ++globalState.runId;
|
|
1837
1833
|
var prevTracking = globalState.trackingDerivation;
|
|
@@ -1984,7 +1980,6 @@
|
|
|
1984
1980
|
this.runId = 0;
|
|
1985
1981
|
this.mobxGuid = 0;
|
|
1986
1982
|
this.inBatch = 0;
|
|
1987
|
-
this.batchId = Number.MIN_SAFE_INTEGER;
|
|
1988
1983
|
this.pendingUnobservations = [];
|
|
1989
1984
|
this.pendingReactions = [];
|
|
1990
1985
|
this.isRunningReactions = false;
|
|
@@ -2001,7 +1996,6 @@
|
|
|
2001
1996
|
this.useProxies = true;
|
|
2002
1997
|
this.verifyProxies = false;
|
|
2003
1998
|
this.safeDescriptors = true;
|
|
2004
|
-
this.stateVersion = Number.MIN_SAFE_INTEGER;
|
|
2005
1999
|
};
|
|
2006
2000
|
var canMergeGlobalState = true;
|
|
2007
2001
|
var isolateCalled = false;
|
|
@@ -2124,9 +2118,6 @@
|
|
|
2124
2118
|
* Avoids unnecessary recalculations.
|
|
2125
2119
|
*/
|
|
2126
2120
|
function startBatch() {
|
|
2127
|
-
if (globalState.inBatch === 0) {
|
|
2128
|
-
globalState.batchId = globalState.batchId < Number.MAX_SAFE_INTEGER ? globalState.batchId + 1 : Number.MIN_SAFE_INTEGER;
|
|
2129
|
-
}
|
|
2130
2121
|
globalState.inBatch++;
|
|
2131
2122
|
}
|
|
2132
2123
|
function endBatch() {
|
|
@@ -2677,7 +2668,6 @@
|
|
|
2677
2668
|
var firstTime = true;
|
|
2678
2669
|
var isScheduled = false;
|
|
2679
2670
|
var value;
|
|
2680
|
-
var oldValue;
|
|
2681
2671
|
var equals = opts.compareStructural ? comparer.structural : opts.equals || comparer["default"];
|
|
2682
2672
|
var r = new Reaction(name, function () {
|
|
2683
2673
|
if (firstTime || runSync) {
|
|
@@ -2693,12 +2683,12 @@
|
|
|
2693
2683
|
return;
|
|
2694
2684
|
}
|
|
2695
2685
|
var changed = false;
|
|
2686
|
+
var oldValue = value;
|
|
2696
2687
|
r.track(function () {
|
|
2697
2688
|
var nextValue = allowStateChanges(false, function () {
|
|
2698
2689
|
return expression(r);
|
|
2699
2690
|
});
|
|
2700
2691
|
changed = firstTime || !equals(value, nextValue);
|
|
2701
|
-
oldValue = value;
|
|
2702
2692
|
value = nextValue;
|
|
2703
2693
|
});
|
|
2704
2694
|
if (firstTime && opts.fireImmediately) {
|
|
@@ -3963,6 +3953,7 @@
|
|
|
3963
3953
|
* Without this, everything works as well, but this works
|
|
3964
3954
|
* faster as everything works on unproxied values
|
|
3965
3955
|
*/
|
|
3956
|
+
addArrayExtension("at", simpleFunc);
|
|
3966
3957
|
addArrayExtension("concat", simpleFunc);
|
|
3967
3958
|
addArrayExtension("flat", simpleFunc);
|
|
3968
3959
|
addArrayExtension("includes", simpleFunc);
|
|
@@ -3972,15 +3963,21 @@
|
|
|
3972
3963
|
addArrayExtension("slice", simpleFunc);
|
|
3973
3964
|
addArrayExtension("toString", simpleFunc);
|
|
3974
3965
|
addArrayExtension("toLocaleString", simpleFunc);
|
|
3966
|
+
addArrayExtension("toSorted", simpleFunc);
|
|
3967
|
+
addArrayExtension("toSpliced", simpleFunc);
|
|
3968
|
+
addArrayExtension("with", simpleFunc);
|
|
3975
3969
|
// map
|
|
3976
3970
|
addArrayExtension("every", mapLikeFunc);
|
|
3977
3971
|
addArrayExtension("filter", mapLikeFunc);
|
|
3978
3972
|
addArrayExtension("find", mapLikeFunc);
|
|
3979
3973
|
addArrayExtension("findIndex", mapLikeFunc);
|
|
3974
|
+
addArrayExtension("findLast", mapLikeFunc);
|
|
3975
|
+
addArrayExtension("findLastIndex", mapLikeFunc);
|
|
3980
3976
|
addArrayExtension("flatMap", mapLikeFunc);
|
|
3981
3977
|
addArrayExtension("forEach", mapLikeFunc);
|
|
3982
3978
|
addArrayExtension("map", mapLikeFunc);
|
|
3983
3979
|
addArrayExtension("some", mapLikeFunc);
|
|
3980
|
+
addArrayExtension("toReversed", mapLikeFunc);
|
|
3984
3981
|
// reduce
|
|
3985
3982
|
addArrayExtension("reduce", reduceLikeFunc);
|
|
3986
3983
|
addArrayExtension("reduceRight", reduceLikeFunc);
|
|
@@ -3998,7 +3995,7 @@
|
|
|
3998
3995
|
return dehancedValues[funcName].apply(dehancedValues, arguments);
|
|
3999
3996
|
};
|
|
4000
3997
|
}
|
|
4001
|
-
// Make sure callbacks
|
|
3998
|
+
// Make sure callbacks receive correct array arg #2326
|
|
4002
3999
|
function mapLikeFunc(funcName) {
|
|
4003
4000
|
return function (callback, thisArg) {
|
|
4004
4001
|
var _this2 = this;
|
|
@@ -4010,7 +4007,7 @@
|
|
|
4010
4007
|
});
|
|
4011
4008
|
};
|
|
4012
4009
|
}
|
|
4013
|
-
// Make sure callbacks
|
|
4010
|
+
// Make sure callbacks receive correct array arg #2326
|
|
4014
4011
|
function reduceLikeFunc(funcName) {
|
|
4015
4012
|
return function () {
|
|
4016
4013
|
var _this3 = this;
|
|
@@ -5343,7 +5340,7 @@
|
|
|
5343
5340
|
_this.spliceWithArray(0, 0, initialValues);
|
|
5344
5341
|
}
|
|
5345
5342
|
if (safariPrototypeSetterInheritanceBug) {
|
|
5346
|
-
// Seems that Safari won't use numeric prototype setter
|
|
5343
|
+
// Seems that Safari won't use numeric prototype setter until any * numeric property is
|
|
5347
5344
|
// defined on the instance. After that it works fine, even if this property is deleted.
|
|
5348
5345
|
Object.defineProperty(_assertThisInitialized(_this), "0", ENTRY_0);
|
|
5349
5346
|
}
|