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/package.json
CHANGED
package/src/core/action.ts
CHANGED
|
@@ -50,6 +50,7 @@ export function createAction(
|
|
|
50
50
|
return executeAction(actionName, autoAction, fn, ref || this, arguments)
|
|
51
51
|
}
|
|
52
52
|
res.isMobxAction = true
|
|
53
|
+
res.toString = () => fn.toString()
|
|
53
54
|
if (isFunctionNameConfigurable) {
|
|
54
55
|
tmpNameDescriptor.value = actionName
|
|
55
56
|
defineProperty(res, "name", tmpNameDescriptor)
|
package/src/core/atom.ts
CHANGED
|
@@ -11,8 +11,7 @@ import {
|
|
|
11
11
|
propagateChanged,
|
|
12
12
|
reportObserved,
|
|
13
13
|
startBatch,
|
|
14
|
-
Lambda
|
|
15
|
-
globalState
|
|
14
|
+
Lambda
|
|
16
15
|
} from "../internal"
|
|
17
16
|
|
|
18
17
|
export const $mobx = Symbol("mobx administration")
|
|
@@ -27,7 +26,6 @@ export class Atom implements IAtom {
|
|
|
27
26
|
isBeingObserved_ = false
|
|
28
27
|
observers_ = new Set<IDerivation>()
|
|
29
28
|
|
|
30
|
-
batchId_: number
|
|
31
29
|
diffValue_ = 0
|
|
32
30
|
lastAccessedBy_ = 0
|
|
33
31
|
lowestObserverState_ = IDerivationState_.NOT_TRACKING_
|
|
@@ -35,9 +33,7 @@ export class Atom implements IAtom {
|
|
|
35
33
|
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
36
34
|
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
37
35
|
*/
|
|
38
|
-
constructor(public name_ = __DEV__ ? "Atom@" + getNextId() : "Atom") {
|
|
39
|
-
this.batchId_ = globalState.inBatch ? globalState.batchId : NaN
|
|
40
|
-
}
|
|
36
|
+
constructor(public name_ = __DEV__ ? "Atom@" + getNextId() : "Atom") {}
|
|
41
37
|
|
|
42
38
|
// onBecomeObservedListeners
|
|
43
39
|
public onBOL: Set<Lambda> | undefined
|
|
@@ -68,17 +64,6 @@ export class Atom implements IAtom {
|
|
|
68
64
|
* Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
|
|
69
65
|
*/
|
|
70
66
|
public reportChanged() {
|
|
71
|
-
if (!globalState.inBatch || this.batchId_ !== globalState.batchId) {
|
|
72
|
-
// We could update state version only at the end of batch,
|
|
73
|
-
// but we would still have to switch some global flag here to signal a change.
|
|
74
|
-
globalState.stateVersion =
|
|
75
|
-
globalState.stateVersion < Number.MAX_SAFE_INTEGER
|
|
76
|
-
? globalState.stateVersion + 1
|
|
77
|
-
: Number.MIN_SAFE_INTEGER
|
|
78
|
-
// Avoids the possibility of hitting the same globalState.batchId when it cycled through all integers (necessary?)
|
|
79
|
-
this.batchId_ = NaN
|
|
80
|
-
}
|
|
81
|
-
|
|
82
67
|
startBatch()
|
|
83
68
|
propagateChanged(this)
|
|
84
69
|
endBatch()
|
package/src/core/globalstate.ts
CHANGED
|
@@ -63,12 +63,6 @@ export class MobXGlobals {
|
|
|
63
63
|
*/
|
|
64
64
|
inBatch: number = 0
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
* ID of the latest batch. Used to suppress reportChanged of newly created atoms.
|
|
68
|
-
* Note the value persists even after batch ended.
|
|
69
|
-
*/
|
|
70
|
-
batchId: number = Number.MIN_SAFE_INTEGER
|
|
71
|
-
|
|
72
66
|
/**
|
|
73
67
|
* Observables that don't have observers anymore, and are about to be
|
|
74
68
|
* suspended, unless somebody else accesses it in the same batch
|
|
@@ -156,11 +150,6 @@ export class MobXGlobals {
|
|
|
156
150
|
* configurable: true
|
|
157
151
|
*/
|
|
158
152
|
safeDescriptors = true
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Changes with each state update, used by useSyncExternalStore
|
|
162
|
-
*/
|
|
163
|
-
stateVersion = Number.MIN_SAFE_INTEGER
|
|
164
153
|
}
|
|
165
154
|
|
|
166
155
|
let canMergeGlobalState = true
|
package/src/core/observable.ts
CHANGED
|
@@ -104,12 +104,6 @@ export function queueForUnobservation(observable: IObservable) {
|
|
|
104
104
|
* Avoids unnecessary recalculations.
|
|
105
105
|
*/
|
|
106
106
|
export function startBatch() {
|
|
107
|
-
if (globalState.inBatch === 0) {
|
|
108
|
-
globalState.batchId =
|
|
109
|
-
globalState.batchId < Number.MAX_SAFE_INTEGER
|
|
110
|
-
? globalState.batchId + 1
|
|
111
|
-
: Number.MIN_SAFE_INTEGER
|
|
112
|
-
}
|
|
113
107
|
globalState.inBatch++
|
|
114
108
|
}
|
|
115
109
|
|
|
@@ -518,6 +518,7 @@ export var arrayExtensions = {
|
|
|
518
518
|
* Without this, everything works as well, but this works
|
|
519
519
|
* faster as everything works on unproxied values
|
|
520
520
|
*/
|
|
521
|
+
addArrayExtension("at", simpleFunc)
|
|
521
522
|
addArrayExtension("concat", simpleFunc)
|
|
522
523
|
addArrayExtension("flat", simpleFunc)
|
|
523
524
|
addArrayExtension("includes", simpleFunc)
|
|
@@ -527,15 +528,21 @@ addArrayExtension("lastIndexOf", simpleFunc)
|
|
|
527
528
|
addArrayExtension("slice", simpleFunc)
|
|
528
529
|
addArrayExtension("toString", simpleFunc)
|
|
529
530
|
addArrayExtension("toLocaleString", simpleFunc)
|
|
531
|
+
addArrayExtension("toSorted", simpleFunc)
|
|
532
|
+
addArrayExtension("toSpliced", simpleFunc)
|
|
533
|
+
addArrayExtension("with", simpleFunc)
|
|
530
534
|
// map
|
|
531
535
|
addArrayExtension("every", mapLikeFunc)
|
|
532
536
|
addArrayExtension("filter", mapLikeFunc)
|
|
533
537
|
addArrayExtension("find", mapLikeFunc)
|
|
534
538
|
addArrayExtension("findIndex", mapLikeFunc)
|
|
539
|
+
addArrayExtension("findLast", mapLikeFunc)
|
|
540
|
+
addArrayExtension("findLastIndex", mapLikeFunc)
|
|
535
541
|
addArrayExtension("flatMap", mapLikeFunc)
|
|
536
542
|
addArrayExtension("forEach", mapLikeFunc)
|
|
537
543
|
addArrayExtension("map", mapLikeFunc)
|
|
538
544
|
addArrayExtension("some", mapLikeFunc)
|
|
545
|
+
addArrayExtension("toReversed", mapLikeFunc)
|
|
539
546
|
// reduce
|
|
540
547
|
addArrayExtension("reduce", reduceLikeFunc)
|
|
541
548
|
addArrayExtension("reduceRight", reduceLikeFunc)
|