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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# mobx
|
|
2
2
|
|
|
3
|
+
## 6.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`ec5db592`](https://github.com/mobxjs/mobx/commit/ec5db592d7756826c31e710b1c759d7e9406b153) [#3792](https://github.com/mobxjs/mobx/pull/3792) Thanks [@tonyraoul](https://github.com/tonyraoul)! - Improve observablearray proxy pefromance for es2023.array and es2022.array methods
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`86616c11`](https://github.com/mobxjs/mobx/commit/86616c11c108a511331eb05e55c08fc2c5a23f4d) [#3654](https://github.com/mobxjs/mobx/pull/3654) Thanks [@ahoisl](https://github.com/ahoisl)! - fix: action transparently forwards toString of underlying function
|
|
12
|
+
|
|
3
13
|
## 6.11.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -23,36 +23,36 @@ Documentation can be found at **[mobx.js.org](https://mobx.js.org/)**.
|
|
|
23
23
|
|
|
24
24
|
MobX is made possible by the generosity of the sponsors below, and many other [individual backers](https://github.com/mobxjs/mobx/blob/main/docs/backers-sponsors.md#backers). Sponsoring directly impacts the longevity of this project.
|
|
25
25
|
|
|
26
|
-
**🥇 Gold sponsors (\$
|
|
27
|
-
|
|
26
|
+
**🥇 Gold sponsors (\$2500+ total contribution):**
|
|
27
|
+
|
|
28
|
+
<br/>
|
|
28
29
|
<a href="https://www.guilded.gg/"><img src="https://mobx.js.org/assets/guilded.jpg" align="center" width="100" title="Guilded" alt="Guilded" /></a>
|
|
29
30
|
<a href="https://www.getparallax.com/"><img src="https://mobx.js.org/assets/parallax.png" align="center" width="100" title="Parallax" alt="Parallax" /></a>
|
|
30
|
-
<a href="https://frontendmasters.com/"><img src="https://mobx.js.org/assets/frontendmasters.jpg" align="center" width="100" title="Frontend Masters" alt="Frontend Masters"></a>
|
|
31
31
|
<a href="https://www.one-beyond.com"><img src="https://mobx.js.org/assets/dcsl.png" align="center" width="100" title="One Beyond" alt="One Beyond"/></a>
|
|
32
|
+
<a href="https://frontendmasters.com/"><img src="https://mobx.js.org/assets/frontendmasters.jpg" align="center" width="100" title="Frontend Masters" alt="Frontend Masters"></a>
|
|
32
33
|
<a href="http://auctionfrontier.com/"><img src="https://mobx.js.org/assets/auctionfrontier.jpeg" align="center" width="100" title="Auction Frontier" alt="Auction Frontier"></a>
|
|
33
34
|
<a href="https://www.codefirst.co.uk/"><img src="https://mobx.js.org/assets/codefirst.png" align="center" width="100" title="CodeFirst" alt="CodeFirst"/></a>
|
|
34
35
|
<a href="https://modulz.app/"><img src="https://mobx.js.org/assets/modulz.png" align="center" width="100" title="Modulz" alt="Modulz"/></a>
|
|
35
36
|
<a href="https://coinbase.com/"><img src="https://mobx.js.org/assets/coinbase.jpeg" align="center" width="100" title="Coinbase" alt="Coinbase" /></a>
|
|
36
37
|
<a href="https://curology.com/blog/tech"><img src="https://mobx.js.org/assets/curology.png" align="center" width="100" title="Curology" alt="Curology"/></a>
|
|
37
|
-
<a href="https://
|
|
38
|
+
<a href="https://mendix.com/"><img src="https://mobx.js.org/assets/mendix-logo.png" align="center" width="100" title="Mendix" alt="Mendix" /></a>
|
|
38
39
|
<a href="https://www.canva.com/"><img src="https://mobx.js.org/assets/canva.svg" align="center" width="100" title="Canva" alt="Canva" /></a>
|
|
39
|
-
|
|
40
|
-
**🥈 Silver sponsors (\$100+ per month):**<br/>
|
|
41
|
-
|
|
40
|
+
<a href="https://opensource.facebook.com/"><img src="https://mobx.js.org/assets/fbos.jpeg" align="center" width="100" title="Facebook Open Source" alt="Facebook Open Source" /></a>
|
|
42
41
|
<a href="https://casinosites.ltd.uk/?utm_source=sponsorship&utm_medium=mobx&utm_campaign=readme"><img src="https://mobx.js.org/assets/casino2.png" align="center" width="100" title="Casino Sites" alt="Casino Sites"/></a>
|
|
43
|
-
<a href="https://upper.co/?utm_source=github_mobxjs_sponsorship&utm_medium=paid_acquisition&utm_campaign=sponsorship"><img src="https://mobx.js.org/assets/upper.png" align="center" width="100" title="UPPER" alt="UPPER"/></a>
|
|
44
|
-
<a href="https://www.easeus.com/?utm_source=github_mobxjs_sponsorship&utm_medium=readme&utm_campaign=sponsorship"><img src="https://mobx.js.org/assets/easeus.png" align="center" width="100" title="EaseUS" alt="EaseUS"/></a>
|
|
45
|
-
|
|
46
|
-
**🥉 Bronze sponsors (\$500+ total contributions):**<br/>
|
|
47
42
|
<a href="https://www.bugsnag.com/platforms/react-error-reporting?utm_source=MobX&utm_medium=Website&utm_content=open-source&utm_campaign=2019-community&utm_term=20190913"><img src="https://mobx.js.org/assets/bugsnag.jpg" align="center" width="100" title="Bugsnag" alt="Bugsnag"/></a>
|
|
48
|
-
|
|
43
|
+
|
|
44
|
+
**🥈 Silver sponsors (\$500+ total contributions):**<br/>
|
|
45
|
+
|
|
49
46
|
<a href="https://mantro.net/jobs/warlock"><img src="https://mobx.js.org/assets/mantro.png" align="center" width="100" title="mantro GmbH" alt="mantro GmbH"></a>
|
|
47
|
+
<a href="https://www.xh.com/"><img src="https://mobx.js.org/assets/xh.png" align="center" width="100" title="Extremely Heavy" alt="Extremely Heavy" /></a>
|
|
50
48
|
<a href="https://www.algolia.com/"><img src="https://mobx.js.org/assets/algolia.jpg" align="center" width="100" title="Algolia" alt="Algolia" /></a>
|
|
51
|
-
<a href="https://
|
|
52
|
-
<a href="https://careers.dazn.com/"><img src="https://mobx.js.org/assets/dazn.png" align="center" width="100" title="DAZN" alt="DAZN"></a>
|
|
49
|
+
<a href="https://space307.com/?utm_source=sponsorship&utm_medium=mobx&utm_campaign=readme"><img src="https://mobx.js.org/assets/space307.png" align="center" width="100" title="Space307" alt="Space307"/></a>
|
|
53
50
|
<a href="https://blokt.com/"><img src="https://mobx.js.org/assets/blokt.jpg" align="center" width="100" title="Blokt" alt="Blokt"/></a>
|
|
51
|
+
<a href="https://upper.co/?utm_source=github_mobxjs_sponsorship&utm_medium=paid_acquisition&utm_campaign=sponsorship"><img src="https://mobx.js.org/assets/upper.png" align="center" width="100" title="UPPER" alt="UPPER"/></a>
|
|
52
|
+
<a href="https://careers.dazn.com/"><img src="https://mobx.js.org/assets/dazn.png" align="center" width="100" title="DAZN" alt="DAZN"></a>
|
|
53
|
+
<a href="https://talentplot.com/"><img src="https://mobx.js.org/assets/talentplot.png" align="center" width="100" title="talentplot" alt="talentplot"></a>
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
## <a href="https://www.easeus.com/?utm_source=github_mobxjs_sponsorship&utm_medium=readme&utm_campaign=sponsorship"><img src="https://mobx.js.org/assets/easeus.png" align="center" width="100" title="EaseUS" alt="EaseUS"/></a>
|
|
56
56
|
|
|
57
57
|
## Introduction
|
|
58
58
|
|
|
@@ -106,26 +106,22 @@ So what does code that uses MobX look like?
|
|
|
106
106
|
import React from "react"
|
|
107
107
|
import ReactDOM from "react-dom"
|
|
108
108
|
import { makeAutoObservable } from "mobx"
|
|
109
|
-
import { observer } from "mobx-react"
|
|
109
|
+
import { observer } from "mobx-react-lite"
|
|
110
110
|
|
|
111
111
|
// Model the application state.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
reset() {
|
|
124
|
-
this.secondsPassed = 0
|
|
125
|
-
}
|
|
112
|
+
function createTimer() {
|
|
113
|
+
return makeAutoObservable({
|
|
114
|
+
secondsPassed: 0,
|
|
115
|
+
increase() {
|
|
116
|
+
this.secondsPassed += 1
|
|
117
|
+
},
|
|
118
|
+
reset() {
|
|
119
|
+
this.secondsPassed = 0
|
|
120
|
+
}
|
|
121
|
+
})
|
|
126
122
|
}
|
|
127
123
|
|
|
128
|
-
const myTimer =
|
|
124
|
+
const myTimer = createTimer()
|
|
129
125
|
|
|
130
126
|
// Build a "user interface" that uses the observable state.
|
|
131
127
|
const TimerView = observer(({ timer }) => (
|
package/dist/core/atom.d.ts
CHANGED
|
@@ -37,11 +37,6 @@ export declare class MobXGlobals {
|
|
|
37
37
|
* Are we in a batch block? (and how many of them)
|
|
38
38
|
*/
|
|
39
39
|
inBatch: number;
|
|
40
|
-
/**
|
|
41
|
-
* ID of the latest batch. Used to suppress reportChanged of newly created atoms.
|
|
42
|
-
* Note the value persists even after batch ended.
|
|
43
|
-
*/
|
|
44
|
-
batchId: number;
|
|
45
40
|
/**
|
|
46
41
|
* Observables that don't have observers anymore, and are about to be
|
|
47
42
|
* suspended, unless somebody else accesses it in the same batch
|
|
@@ -106,10 +101,6 @@ export declare class MobXGlobals {
|
|
|
106
101
|
* configurable: true
|
|
107
102
|
*/
|
|
108
103
|
safeDescriptors: boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Changes with each state update, used by useSyncExternalStore
|
|
111
|
-
*/
|
|
112
|
-
stateVersion: number;
|
|
113
104
|
}
|
|
114
105
|
export declare let globalState: MobXGlobals;
|
|
115
106
|
export declare function isolateGlobalState(): void;
|
|
@@ -440,14 +440,12 @@ var Atom = /*#__PURE__*/function () {
|
|
|
440
440
|
this.isPendingUnobservation_ = false;
|
|
441
441
|
this.isBeingObserved_ = false;
|
|
442
442
|
this.observers_ = new Set();
|
|
443
|
-
this.batchId_ = void 0;
|
|
444
443
|
this.diffValue_ = 0;
|
|
445
444
|
this.lastAccessedBy_ = 0;
|
|
446
445
|
this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_;
|
|
447
446
|
this.onBOL = void 0;
|
|
448
447
|
this.onBUOL = void 0;
|
|
449
448
|
this.name_ = name_;
|
|
450
|
-
this.batchId_ = globalState.inBatch ? globalState.batchId : NaN;
|
|
451
449
|
}
|
|
452
450
|
// onBecomeObservedListeners
|
|
453
451
|
var _proto = Atom.prototype;
|
|
@@ -476,13 +474,6 @@ var Atom = /*#__PURE__*/function () {
|
|
|
476
474
|
* Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
|
|
477
475
|
*/;
|
|
478
476
|
_proto.reportChanged = function reportChanged() {
|
|
479
|
-
if (!globalState.inBatch || this.batchId_ !== globalState.batchId) {
|
|
480
|
-
// We could update state version only at the end of batch,
|
|
481
|
-
// but we would still have to switch some global flag here to signal a change.
|
|
482
|
-
globalState.stateVersion = globalState.stateVersion < Number.MAX_SAFE_INTEGER ? globalState.stateVersion + 1 : Number.MIN_SAFE_INTEGER;
|
|
483
|
-
// Avoids the possibility of hitting the same globalState.batchId when it cycled through all integers (necessary?)
|
|
484
|
-
this.batchId_ = NaN;
|
|
485
|
-
}
|
|
486
477
|
startBatch();
|
|
487
478
|
propagateChanged(this);
|
|
488
479
|
endBatch();
|
|
@@ -1235,6 +1226,9 @@ function createAction(actionName, fn, autoAction, ref) {
|
|
|
1235
1226
|
return executeAction(actionName, autoAction, fn, ref || this, arguments);
|
|
1236
1227
|
}
|
|
1237
1228
|
res.isMobxAction = true;
|
|
1229
|
+
res.toString = function () {
|
|
1230
|
+
return fn.toString();
|
|
1231
|
+
};
|
|
1238
1232
|
if (isFunctionNameConfigurable) {
|
|
1239
1233
|
tmpNameDescriptor.value = actionName;
|
|
1240
1234
|
defineProperty(res, "name", tmpNameDescriptor);
|
|
@@ -1982,7 +1976,6 @@ var MobXGlobals = function MobXGlobals() {
|
|
|
1982
1976
|
this.runId = 0;
|
|
1983
1977
|
this.mobxGuid = 0;
|
|
1984
1978
|
this.inBatch = 0;
|
|
1985
|
-
this.batchId = Number.MIN_SAFE_INTEGER;
|
|
1986
1979
|
this.pendingUnobservations = [];
|
|
1987
1980
|
this.pendingReactions = [];
|
|
1988
1981
|
this.isRunningReactions = false;
|
|
@@ -1999,7 +1992,6 @@ var MobXGlobals = function MobXGlobals() {
|
|
|
1999
1992
|
this.useProxies = true;
|
|
2000
1993
|
this.verifyProxies = false;
|
|
2001
1994
|
this.safeDescriptors = true;
|
|
2002
|
-
this.stateVersion = Number.MIN_SAFE_INTEGER;
|
|
2003
1995
|
};
|
|
2004
1996
|
var canMergeGlobalState = true;
|
|
2005
1997
|
var isolateCalled = false;
|
|
@@ -2122,9 +2114,6 @@ function queueForUnobservation(observable) {
|
|
|
2122
2114
|
* Avoids unnecessary recalculations.
|
|
2123
2115
|
*/
|
|
2124
2116
|
function startBatch() {
|
|
2125
|
-
if (globalState.inBatch === 0) {
|
|
2126
|
-
globalState.batchId = globalState.batchId < Number.MAX_SAFE_INTEGER ? globalState.batchId + 1 : Number.MIN_SAFE_INTEGER;
|
|
2127
|
-
}
|
|
2128
2117
|
globalState.inBatch++;
|
|
2129
2118
|
}
|
|
2130
2119
|
function endBatch() {
|
|
@@ -3961,6 +3950,7 @@ var arrayExtensions = {
|
|
|
3961
3950
|
* Without this, everything works as well, but this works
|
|
3962
3951
|
* faster as everything works on unproxied values
|
|
3963
3952
|
*/
|
|
3953
|
+
addArrayExtension("at", simpleFunc);
|
|
3964
3954
|
addArrayExtension("concat", simpleFunc);
|
|
3965
3955
|
addArrayExtension("flat", simpleFunc);
|
|
3966
3956
|
addArrayExtension("includes", simpleFunc);
|
|
@@ -3970,15 +3960,21 @@ addArrayExtension("lastIndexOf", simpleFunc);
|
|
|
3970
3960
|
addArrayExtension("slice", simpleFunc);
|
|
3971
3961
|
addArrayExtension("toString", simpleFunc);
|
|
3972
3962
|
addArrayExtension("toLocaleString", simpleFunc);
|
|
3963
|
+
addArrayExtension("toSorted", simpleFunc);
|
|
3964
|
+
addArrayExtension("toSpliced", simpleFunc);
|
|
3965
|
+
addArrayExtension("with", simpleFunc);
|
|
3973
3966
|
// map
|
|
3974
3967
|
addArrayExtension("every", mapLikeFunc);
|
|
3975
3968
|
addArrayExtension("filter", mapLikeFunc);
|
|
3976
3969
|
addArrayExtension("find", mapLikeFunc);
|
|
3977
3970
|
addArrayExtension("findIndex", mapLikeFunc);
|
|
3971
|
+
addArrayExtension("findLast", mapLikeFunc);
|
|
3972
|
+
addArrayExtension("findLastIndex", mapLikeFunc);
|
|
3978
3973
|
addArrayExtension("flatMap", mapLikeFunc);
|
|
3979
3974
|
addArrayExtension("forEach", mapLikeFunc);
|
|
3980
3975
|
addArrayExtension("map", mapLikeFunc);
|
|
3981
3976
|
addArrayExtension("some", mapLikeFunc);
|
|
3977
|
+
addArrayExtension("toReversed", mapLikeFunc);
|
|
3982
3978
|
// reduce
|
|
3983
3979
|
addArrayExtension("reduce", reduceLikeFunc);
|
|
3984
3980
|
addArrayExtension("reduceRight", reduceLikeFunc);
|