mobx 6.11.0 → 6.12.0
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 +10 -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 +10 -14
- 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 +10 -14
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +10 -14
- 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 +10 -14
- 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/core/action.ts +1 -0
- package/src/core/atom.ts +2 -17
- package/src/core/globalstate.ts +0 -11
- package/src/core/observable.ts +0 -6
- package/src/types/observablearray.ts +7 -0
package/dist/mobx.esm.js
CHANGED
|
@@ -437,14 +437,12 @@ var Atom = /*#__PURE__*/function () {
|
|
|
437
437
|
this.isPendingUnobservation_ = false;
|
|
438
438
|
this.isBeingObserved_ = false;
|
|
439
439
|
this.observers_ = new Set();
|
|
440
|
-
this.batchId_ = void 0;
|
|
441
440
|
this.diffValue_ = 0;
|
|
442
441
|
this.lastAccessedBy_ = 0;
|
|
443
442
|
this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_;
|
|
444
443
|
this.onBOL = void 0;
|
|
445
444
|
this.onBUOL = void 0;
|
|
446
445
|
this.name_ = name_;
|
|
447
|
-
this.batchId_ = globalState.inBatch ? globalState.batchId : NaN;
|
|
448
446
|
}
|
|
449
447
|
// onBecomeObservedListeners
|
|
450
448
|
var _proto = Atom.prototype;
|
|
@@ -473,13 +471,6 @@ var Atom = /*#__PURE__*/function () {
|
|
|
473
471
|
* Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
|
|
474
472
|
*/;
|
|
475
473
|
_proto.reportChanged = function reportChanged() {
|
|
476
|
-
if (!globalState.inBatch || this.batchId_ !== globalState.batchId) {
|
|
477
|
-
// We could update state version only at the end of batch,
|
|
478
|
-
// but we would still have to switch some global flag here to signal a change.
|
|
479
|
-
globalState.stateVersion = globalState.stateVersion < Number.MAX_SAFE_INTEGER ? globalState.stateVersion + 1 : Number.MIN_SAFE_INTEGER;
|
|
480
|
-
// Avoids the possibility of hitting the same globalState.batchId when it cycled through all integers (necessary?)
|
|
481
|
-
this.batchId_ = NaN;
|
|
482
|
-
}
|
|
483
474
|
startBatch();
|
|
484
475
|
propagateChanged(this);
|
|
485
476
|
endBatch();
|
|
@@ -1232,6 +1223,9 @@ function createAction(actionName, fn, autoAction, ref) {
|
|
|
1232
1223
|
return executeAction(actionName, autoAction, fn, ref || this, arguments);
|
|
1233
1224
|
}
|
|
1234
1225
|
res.isMobxAction = true;
|
|
1226
|
+
res.toString = function () {
|
|
1227
|
+
return fn.toString();
|
|
1228
|
+
};
|
|
1235
1229
|
if (isFunctionNameConfigurable) {
|
|
1236
1230
|
tmpNameDescriptor.value = actionName;
|
|
1237
1231
|
defineProperty(res, "name", tmpNameDescriptor);
|
|
@@ -1988,7 +1982,6 @@ var MobXGlobals = function MobXGlobals() {
|
|
|
1988
1982
|
this.runId = 0;
|
|
1989
1983
|
this.mobxGuid = 0;
|
|
1990
1984
|
this.inBatch = 0;
|
|
1991
|
-
this.batchId = Number.MIN_SAFE_INTEGER;
|
|
1992
1985
|
this.pendingUnobservations = [];
|
|
1993
1986
|
this.pendingReactions = [];
|
|
1994
1987
|
this.isRunningReactions = false;
|
|
@@ -2005,7 +1998,6 @@ var MobXGlobals = function MobXGlobals() {
|
|
|
2005
1998
|
this.useProxies = true;
|
|
2006
1999
|
this.verifyProxies = false;
|
|
2007
2000
|
this.safeDescriptors = true;
|
|
2008
|
-
this.stateVersion = Number.MIN_SAFE_INTEGER;
|
|
2009
2001
|
};
|
|
2010
2002
|
var canMergeGlobalState = true;
|
|
2011
2003
|
var isolateCalled = false;
|
|
@@ -2128,9 +2120,6 @@ function queueForUnobservation(observable) {
|
|
|
2128
2120
|
* Avoids unnecessary recalculations.
|
|
2129
2121
|
*/
|
|
2130
2122
|
function startBatch() {
|
|
2131
|
-
if (globalState.inBatch === 0) {
|
|
2132
|
-
globalState.batchId = globalState.batchId < Number.MAX_SAFE_INTEGER ? globalState.batchId + 1 : Number.MIN_SAFE_INTEGER;
|
|
2133
|
-
}
|
|
2134
2123
|
globalState.inBatch++;
|
|
2135
2124
|
}
|
|
2136
2125
|
function endBatch() {
|
|
@@ -3982,6 +3971,7 @@ var arrayExtensions = {
|
|
|
3982
3971
|
* Without this, everything works as well, but this works
|
|
3983
3972
|
* faster as everything works on unproxied values
|
|
3984
3973
|
*/
|
|
3974
|
+
addArrayExtension("at", simpleFunc);
|
|
3985
3975
|
addArrayExtension("concat", simpleFunc);
|
|
3986
3976
|
addArrayExtension("flat", simpleFunc);
|
|
3987
3977
|
addArrayExtension("includes", simpleFunc);
|
|
@@ -3991,15 +3981,21 @@ addArrayExtension("lastIndexOf", simpleFunc);
|
|
|
3991
3981
|
addArrayExtension("slice", simpleFunc);
|
|
3992
3982
|
addArrayExtension("toString", simpleFunc);
|
|
3993
3983
|
addArrayExtension("toLocaleString", simpleFunc);
|
|
3984
|
+
addArrayExtension("toSorted", simpleFunc);
|
|
3985
|
+
addArrayExtension("toSpliced", simpleFunc);
|
|
3986
|
+
addArrayExtension("with", simpleFunc);
|
|
3994
3987
|
// map
|
|
3995
3988
|
addArrayExtension("every", mapLikeFunc);
|
|
3996
3989
|
addArrayExtension("filter", mapLikeFunc);
|
|
3997
3990
|
addArrayExtension("find", mapLikeFunc);
|
|
3998
3991
|
addArrayExtension("findIndex", mapLikeFunc);
|
|
3992
|
+
addArrayExtension("findLast", mapLikeFunc);
|
|
3993
|
+
addArrayExtension("findLastIndex", mapLikeFunc);
|
|
3999
3994
|
addArrayExtension("flatMap", mapLikeFunc);
|
|
4000
3995
|
addArrayExtension("forEach", mapLikeFunc);
|
|
4001
3996
|
addArrayExtension("map", mapLikeFunc);
|
|
4002
3997
|
addArrayExtension("some", mapLikeFunc);
|
|
3998
|
+
addArrayExtension("toReversed", mapLikeFunc);
|
|
4003
3999
|
// reduce
|
|
4004
4000
|
addArrayExtension("reduce", reduceLikeFunc);
|
|
4005
4001
|
addArrayExtension("reduceRight", reduceLikeFunc);
|