mobx 6.3.2 → 6.3.6
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 +37 -0
- package/README.md +4 -4
- package/dist/api/autorun.d.ts +4 -4
- package/dist/mobx.cjs.development.js +59 -54
- 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 +59 -54
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +59 -54
- 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 +59 -54
- 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/dist/types/observablemap.d.ts +0 -1
- package/package.json +1 -1
- package/src/api/autorun.ts +18 -11
- package/src/api/extendobservable.ts +1 -1
- package/src/api/iscomputed.ts +6 -6
- package/src/api/makeObservable.ts +7 -1
- package/src/api/observable.ts +4 -4
- package/src/api/when.ts +2 -2
- package/src/core/computedvalue.ts +19 -17
- package/src/core/derivation.ts +4 -2
- package/src/core/globalstate.ts +2 -0
- package/src/core/observable.ts +1 -1
- package/src/mobx.ts +1 -1
- package/src/types/actionannotation.ts +4 -2
- package/src/types/observablearray.ts +1 -1
- package/src/types/observablemap.ts +2 -9
- package/src/utils/comparer.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# mobx
|
|
2
2
|
|
|
3
|
+
## 6.3.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`49468204`](https://github.com/mobxjs/mobx/commit/49468204d3bc28d15dbf383c0b7f874ca26dff30) [#3162](https://github.com/mobxjs/mobx/pull/3162) Thanks [@upsuper](https://github.com/upsuper)! - Have cancelled when reject with an error rather than a string
|
|
8
|
+
|
|
9
|
+
* [`4afb1ec2`](https://github.com/mobxjs/mobx/commit/4afb1ec24427cf8e1f768d0c6fc49d0f44f4ab8e) [#3154](https://github.com/mobxjs/mobx/pull/3154) Thanks [@urugator](https://github.com/urugator)! - `makeObservable` throws when mixing @decorator syntax with annotations
|
|
10
|
+
|
|
11
|
+
## 6.3.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`4ac6b454`](https://github.com/mobxjs/mobx/commit/4ac6b45473c2e3b07c8e683cd395bc5edfaa8e15) [#3146](https://github.com/mobxjs/mobx/pull/3146) Thanks [@urugator](https://github.com/urugator)! - fix #3109: spy: computed shouldn't report update unless the value changed
|
|
16
|
+
|
|
17
|
+
## 6.3.4
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [`0dbf3eb6`](https://github.com/mobxjs/mobx/commit/0dbf3eb6eecfa9cd6cd9dc7d707e8d70927e79bf) [#3141](https://github.com/mobxjs/mobx/pull/3141) Thanks [@urugator](https://github.com/urugator)! - [spy: bound actions report correct object](https://github.com/mobxjs/mobx/discussions/3140)
|
|
22
|
+
|
|
23
|
+
## 6.3.3
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [`d78a1592`](https://github.com/mobxjs/mobx/commit/d78a15929052b96698b3355a0b4c8335750422db) [#2902](https://github.com/mobxjs/mobx/pull/2902) Thanks [@z3rog](https://github.com/z3rog)! - chore: observable use internal constants
|
|
28
|
+
|
|
29
|
+
* [`db21d85f`](https://github.com/mobxjs/mobx/commit/db21d85fcd41c6c142998f53e722ee0a0e9b5c18) [#2998](https://github.com/mobxjs/mobx/pull/2998) Thanks [@urugator](https://github.com/urugator)! - `trace()`: log when computed becomes suspended
|
|
30
|
+
`requiresReaction` warns instead of throwing
|
|
31
|
+
|
|
32
|
+
- [`b9fa119c`](https://github.com/mobxjs/mobx/commit/b9fa119c90e23d4b327763189f24c00be2fb2c26) [#3056](https://github.com/mobxjs/mobx/pull/3056) Thanks [@upsuper](https://github.com/upsuper)! - Create WHEN_TIMEOUT error earlier to capture useful stack
|
|
33
|
+
|
|
34
|
+
* [`99491ec2`](https://github.com/mobxjs/mobx/commit/99491ec2d315a3a01cdbe40d9a24d920a09cbd0e) [#2972](https://github.com/mobxjs/mobx/pull/2972) Thanks [@kk-gjyang](https://github.com/kk-gjyang)! - Polyfill `Object.is` for old/unsupported browsers
|
|
35
|
+
|
|
36
|
+
- [`0d28db8a`](https://github.com/mobxjs/mobx/commit/0d28db8a0ba99f5cce744bb83b5bd88ec45a7e41) [#2927](https://github.com/mobxjs/mobx/pull/2927) Thanks [@upsuper](https://github.com/upsuper)! - Give proper typing to opts.equals of reaction
|
|
37
|
+
|
|
38
|
+
* [`c6dc925c`](https://github.com/mobxjs/mobx/commit/c6dc925c6cf7eeff9237ee07c55927a7bbc14cb7) [#2985](https://github.com/mobxjs/mobx/pull/2985) Thanks [@fecqs](https://github.com/fecqs)! - Remove duplicate global property check
|
|
39
|
+
|
|
3
40
|
## 6.3.2
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ _Simple, scalable state management._
|
|
|
17
17
|
|
|
18
18
|
MobX is made possible by the generosity of the sponsors below, and many other [individual backers](docs/backers-sponsors.md#backers). Sponsoring directly impacts the longevity of this project.
|
|
19
19
|
|
|
20
|
-
**🥇Gold sponsors (\$3000+ total contribution):** <br/>
|
|
20
|
+
**🥇 Gold sponsors (\$3000+ total contribution):** <br/>
|
|
21
21
|
<a href="https://mendix.com/"><img src="https://mobx.js.org/assets/mendix-logo.png" align="center" width="100" title="Mendix" alt="Mendix" /></a>
|
|
22
22
|
<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>
|
|
23
23
|
<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>
|
|
@@ -26,7 +26,7 @@ MobX is made possible by the generosity of the sponsors below, and many other [i
|
|
|
26
26
|
<a href="https://coinbase.com/"><img src="https://mobx.js.org/assets/coinbase.jpeg" align="center" width="100" title="Coinbase" alt="Coinbase" /></a>
|
|
27
27
|
<a href="https://www.canva.com/"><img src="https://mobx.js.org/assets/canva.png" align="center" width="100" title="Canva" alt="Canva" /></a>
|
|
28
28
|
|
|
29
|
-
**🥈Silver sponsors (\$100+
|
|
29
|
+
**🥈 Silver sponsors (\$100+ per month):**<br/>
|
|
30
30
|
<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>
|
|
31
31
|
<a href="https://www.dcsl.com/"><img src="https://mobx.js.org/assets/dcsl.png" align="center" width="100" title="DCSL Guidesmiths" alt="DCSL Guidesmiths"/></a>
|
|
32
32
|
<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>
|
|
@@ -34,7 +34,7 @@ MobX is made possible by the generosity of the sponsors below, and many other [i
|
|
|
34
34
|
<a href="https://modulz.app/"><img src="https://mobx.js.org/assets/modulz.png" align="center" width="100" title="Modulz" alt="Modulz"/></a>
|
|
35
35
|
<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>
|
|
36
36
|
|
|
37
|
-
**🥉Bronze sponsors (\$500+ total contributions):**<br/>
|
|
37
|
+
**🥉 Bronze sponsors (\$500+ total contributions):**<br/>
|
|
38
38
|
<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>
|
|
39
39
|
<a href="https://www.algolia.com/"><img src="https://mobx.js.org/assets/algolia.jpg" align="center" width="100" title="Algolia" alt="Algolia" /></a>
|
|
40
40
|
<a href="https://talentplot.com/"><img src="https://mobx.js.org/assets/talentplot.png" align="center" width="100" title="talentplot" alt="talentplot"></a>
|
|
@@ -136,7 +136,7 @@ Changes in the observable state are propagated precisely to all _computations_ a
|
|
|
136
136
|
|
|
137
137
|
This conceptual picture can be applied to the above example, or any other application using MobX.
|
|
138
138
|
|
|
139
|
-
To learn about the core concepts of MobX using a larger example, check out [The gist of MobX](
|
|
139
|
+
To learn about the core concepts of MobX using a larger example, check out [The gist of MobX](https://mobx.js.org/the-gist-of-mobx.html) section, or take the [10 minute interactive introduction to MobX and React](https://mobx.js.org/getting-started).
|
|
140
140
|
The philosophy and benefits of the mental model provided by MobX are also described in great detail in the blog posts [UI as an afterthought](https://michel.codes/blogs/ui-as-an-afterthought) and [How to decouple state and UI (a.k.a. you don’t need componentWillMount)](https://hackernoon.com/how-to-decouple-state-and-ui-a-k-a-you-dont-need-componentwillmount-cc90b787aa37).
|
|
141
141
|
|
|
142
142
|
<div class="cheat"><a href="https://gum.co/fSocU"><button title="Download the MobX 6 cheat sheet and sponsor the project">Download the MobX 6 cheat sheet</button></a></div>
|
package/dist/api/autorun.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export interface IAutorunOptions {
|
|
|
17
17
|
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
18
18
|
*/
|
|
19
19
|
export declare function autorun(view: (r: IReactionPublic) => any, opts?: IAutorunOptions): IReactionDisposer;
|
|
20
|
-
export declare type IReactionOptions = IAutorunOptions & {
|
|
21
|
-
fireImmediately?:
|
|
22
|
-
equals?: IEqualsComparer<
|
|
20
|
+
export declare type IReactionOptions<T, FireImmediately extends boolean> = IAutorunOptions & {
|
|
21
|
+
fireImmediately?: FireImmediately;
|
|
22
|
+
equals?: IEqualsComparer<T>;
|
|
23
23
|
};
|
|
24
|
-
export declare function reaction<T>(expression: (r: IReactionPublic) => T, effect: (arg: T, prev: T, r: IReactionPublic) => void, opts?: IReactionOptions): IReactionDisposer;
|
|
24
|
+
export declare function reaction<T, FireImmediately extends boolean = false>(expression: (r: IReactionPublic) => T, effect: (arg: T, prev: FireImmediately extends true ? T | undefined : T, r: IReactionPublic) => void, opts?: IReactionOptions<T, FireImmediately>): IReactionDisposer;
|
|
@@ -514,7 +514,8 @@ function shallowComparer(a, b) {
|
|
|
514
514
|
}
|
|
515
515
|
|
|
516
516
|
function defaultComparer(a, b) {
|
|
517
|
-
return Object.is(a, b);
|
|
517
|
+
if (Object.is) return Object.is(a, b);
|
|
518
|
+
return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
|
|
518
519
|
}
|
|
519
520
|
|
|
520
521
|
var comparer = {
|
|
@@ -674,7 +675,7 @@ function assertActionDescriptor(adm, _ref, key, _ref2) {
|
|
|
674
675
|
|
|
675
676
|
function createActionDescriptor(adm, annotation, key, descriptor, // provides ability to disable safeDescriptors for prototypes
|
|
676
677
|
safeDescriptors) {
|
|
677
|
-
var _annotation$options_, _annotation$options_$, _annotation$options_2, _annotation$options_$2, _annotation$options_3;
|
|
678
|
+
var _annotation$options_, _annotation$options_$, _annotation$options_2, _annotation$options_$2, _annotation$options_3, _annotation$options_4, _adm$proxy_2;
|
|
678
679
|
|
|
679
680
|
if (safeDescriptors === void 0) {
|
|
680
681
|
safeDescriptors = globalState.safeDescriptors;
|
|
@@ -690,7 +691,8 @@ safeDescriptors) {
|
|
|
690
691
|
}
|
|
691
692
|
|
|
692
693
|
return {
|
|
693
|
-
value: createAction((_annotation$options_$ = (_annotation$options_2 = annotation.options_) == null ? void 0 : _annotation$options_2.name) != null ? _annotation$options_$ : key.toString(), value, (_annotation$options_$2 = (_annotation$options_3 = annotation.options_) == null ? void 0 : _annotation$options_3.autoAction) != null ? _annotation$options_$2 : false
|
|
694
|
+
value: createAction((_annotation$options_$ = (_annotation$options_2 = annotation.options_) == null ? void 0 : _annotation$options_2.name) != null ? _annotation$options_$ : key.toString(), value, (_annotation$options_$2 = (_annotation$options_3 = annotation.options_) == null ? void 0 : _annotation$options_3.autoAction) != null ? _annotation$options_$2 : false, // https://github.com/mobxjs/mobx/discussions/3140
|
|
695
|
+
((_annotation$options_4 = annotation.options_) == null ? void 0 : _annotation$options_4.bound) ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
|
|
694
696
|
// Non-configurable for classes
|
|
695
697
|
// prevents accidental field redefinition in subclass
|
|
696
698
|
configurable: safeDescriptors ? adm.isPlainObject_ : true,
|
|
@@ -959,6 +961,10 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
|
959
961
|
return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
|
|
960
962
|
}
|
|
961
963
|
|
|
964
|
+
var OBSERVABLE = "observable";
|
|
965
|
+
var OBSERVABLE_REF = "observable.ref";
|
|
966
|
+
var OBSERVABLE_SHALLOW = "observable.shallow";
|
|
967
|
+
var OBSERVABLE_STRUCT = "observable.struct"; // Predefined bags of create observable options, to avoid allocating temporarily option objects
|
|
962
968
|
// in the majority of cases
|
|
963
969
|
|
|
964
970
|
var defaultCreateObservableOptions = {
|
|
@@ -971,14 +977,14 @@ Object.freeze(defaultCreateObservableOptions);
|
|
|
971
977
|
function asCreateObservableOptions(thing) {
|
|
972
978
|
return thing || defaultCreateObservableOptions;
|
|
973
979
|
}
|
|
974
|
-
var observableAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
975
|
-
var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
980
|
+
var observableAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE);
|
|
981
|
+
var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_REF, {
|
|
976
982
|
enhancer: referenceEnhancer
|
|
977
983
|
});
|
|
978
|
-
var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
984
|
+
var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_SHALLOW, {
|
|
979
985
|
enhancer: shallowEnhancer
|
|
980
986
|
});
|
|
981
|
-
var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
987
|
+
var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_STRUCT, {
|
|
982
988
|
enhancer: refStructEnhancer
|
|
983
989
|
});
|
|
984
990
|
var observableDecoratorAnnotation = /*#__PURE__*/createDecoratorAnnotation(observableAnnotation);
|
|
@@ -1533,22 +1539,21 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1533
1539
|
/* see #1208 */
|
|
1534
1540
|
this.dependenciesState_ === IDerivationState_.NOT_TRACKING_;
|
|
1535
1541
|
var newValue = this.computeValue_(true);
|
|
1536
|
-
|
|
1537
|
-
if ( isSpyEnabled()) {
|
|
1538
|
-
spyReport({
|
|
1539
|
-
observableKind: "computed",
|
|
1540
|
-
debugObjectName: this.name_,
|
|
1541
|
-
object: this.scope_,
|
|
1542
|
-
type: "update",
|
|
1543
|
-
oldValue: this.value_,
|
|
1544
|
-
newValue: newValue
|
|
1545
|
-
});
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
1542
|
var changed = wasSuspended || isCaughtException(oldValue) || isCaughtException(newValue) || !this.equals_(oldValue, newValue);
|
|
1549
1543
|
|
|
1550
1544
|
if (changed) {
|
|
1551
1545
|
this.value_ = newValue;
|
|
1546
|
+
|
|
1547
|
+
if ( isSpyEnabled()) {
|
|
1548
|
+
spyReport({
|
|
1549
|
+
observableKind: "computed",
|
|
1550
|
+
debugObjectName: this.name_,
|
|
1551
|
+
object: this.scope_,
|
|
1552
|
+
type: "update",
|
|
1553
|
+
oldValue: oldValue,
|
|
1554
|
+
newValue: newValue
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1552
1557
|
}
|
|
1553
1558
|
|
|
1554
1559
|
return changed;
|
|
@@ -1583,6 +1588,10 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1583
1588
|
if (!this.keepAlive_) {
|
|
1584
1589
|
clearObserving(this);
|
|
1585
1590
|
this.value_ = undefined; // don't hold on to computed value!
|
|
1591
|
+
|
|
1592
|
+
if ( this.isTracing_ !== TraceMode.NONE) {
|
|
1593
|
+
console.log("[mobx.trace] Computed value '" + this.name_ + "' was suspended and it will recompute on the next access.");
|
|
1594
|
+
}
|
|
1586
1595
|
}
|
|
1587
1596
|
};
|
|
1588
1597
|
|
|
@@ -1615,16 +1624,12 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1615
1624
|
|
|
1616
1625
|
_proto.warnAboutUntrackedRead_ = function warnAboutUntrackedRead_() {
|
|
1617
1626
|
|
|
1618
|
-
if (this.requiresReaction_ === true) {
|
|
1619
|
-
die("[mobx] Computed value " + this.name_ + " is read outside a reactive context");
|
|
1620
|
-
}
|
|
1621
|
-
|
|
1622
1627
|
if (this.isTracing_ !== TraceMode.NONE) {
|
|
1623
|
-
console.log("[mobx.trace] '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute");
|
|
1628
|
+
console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1624
1629
|
}
|
|
1625
1630
|
|
|
1626
|
-
if (globalState.computedRequiresReaction) {
|
|
1627
|
-
console.warn("[mobx] Computed value " + this.name_ + " is being read outside a reactive context. Doing a full recompute");
|
|
1631
|
+
if (globalState.computedRequiresReaction || this.requiresReaction_) {
|
|
1632
|
+
console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1628
1633
|
}
|
|
1629
1634
|
};
|
|
1630
1635
|
|
|
@@ -1757,7 +1762,7 @@ function checkIfStateModificationsAreAllowed(atom) {
|
|
|
1757
1762
|
}
|
|
1758
1763
|
function checkIfStateReadsAreAllowed(observable) {
|
|
1759
1764
|
if ( !globalState.allowStateReads && globalState.observableRequiresReaction) {
|
|
1760
|
-
console.warn("[mobx] Observable " + observable.name_ + " being read outside a reactive context");
|
|
1765
|
+
console.warn("[mobx] Observable '" + observable.name_ + "' being read outside a reactive context.");
|
|
1761
1766
|
}
|
|
1762
1767
|
}
|
|
1763
1768
|
/**
|
|
@@ -1801,7 +1806,7 @@ function warnAboutDerivationWithoutDependencies(derivation) {
|
|
|
1801
1806
|
if (derivation.observing_.length !== 0) return;
|
|
1802
1807
|
|
|
1803
1808
|
if (globalState.reactionRequiresObservable || derivation.requiresObservable_) {
|
|
1804
|
-
console.warn("[mobx] Derivation " + derivation.name_ + " is created/updated without reading any observable value");
|
|
1809
|
+
console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
|
|
1805
1810
|
}
|
|
1806
1811
|
}
|
|
1807
1812
|
/**
|
|
@@ -1967,6 +1972,8 @@ var globalState = /*#__PURE__*/function () {
|
|
|
1967
1972
|
if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) canMergeGlobalState = false;
|
|
1968
1973
|
|
|
1969
1974
|
if (!canMergeGlobalState) {
|
|
1975
|
+
// Because this is a IIFE we need to let isolateCalled a chance to change
|
|
1976
|
+
// so we run it after the event loop completed at least 1 iteration
|
|
1970
1977
|
setTimeout(function () {
|
|
1971
1978
|
if (!isolateCalled) {
|
|
1972
1979
|
die(35);
|
|
@@ -2214,8 +2221,7 @@ function printDepTree(tree, lines, depth) {
|
|
|
2214
2221
|
return;
|
|
2215
2222
|
}
|
|
2216
2223
|
|
|
2217
|
-
lines.push("" +
|
|
2218
|
-
|
|
2224
|
+
lines.push("" + "\t".repeat(depth - 1) + tree.name);
|
|
2219
2225
|
if (tree.dependencies) tree.dependencies.forEach(function (child) {
|
|
2220
2226
|
return printDepTree(child, lines, depth + 1);
|
|
2221
2227
|
});
|
|
@@ -2646,8 +2652,7 @@ function reaction(expression, effect, opts) {
|
|
|
2646
2652
|
var firstTime = true;
|
|
2647
2653
|
var isScheduled = false;
|
|
2648
2654
|
var value;
|
|
2649
|
-
var oldValue
|
|
2650
|
-
|
|
2655
|
+
var oldValue;
|
|
2651
2656
|
var equals = opts.compareStructural ? comparer.structural : opts.equals || comparer["default"];
|
|
2652
2657
|
var r = new Reaction(name, function () {
|
|
2653
2658
|
if (firstTime || runSync) {
|
|
@@ -2763,7 +2768,7 @@ function extendObservable(target, properties, annotations, options) {
|
|
|
2763
2768
|
if (arguments.length > 4) die("'extendObservable' expected 2-4 arguments");
|
|
2764
2769
|
if (typeof target !== "object") die("'extendObservable' expects an object as first argument");
|
|
2765
2770
|
if (isObservableMap(target)) die("'extendObservable' should not be used on maps, use map.merge instead");
|
|
2766
|
-
if (!isPlainObject(properties)) die("'
|
|
2771
|
+
if (!isPlainObject(properties)) die("'extendObservable' only accepts plain objects as second argument");
|
|
2767
2772
|
if (isObservable(properties) || isObservable(annotations)) die("Extending an object with another observable (object) is not supported");
|
|
2768
2773
|
} // Pull descriptors first, so we don't have to deal with props added by administration ($mobx)
|
|
2769
2774
|
|
|
@@ -2954,14 +2959,14 @@ function interceptProperty(thing, property, handler) {
|
|
|
2954
2959
|
}
|
|
2955
2960
|
|
|
2956
2961
|
function _isComputed(value, property) {
|
|
2957
|
-
if (property
|
|
2958
|
-
|
|
2959
|
-
if (!value[$mobx].values_.has(property)) return false;
|
|
2960
|
-
var atom = getAtom(value, property);
|
|
2961
|
-
return isComputedValue(atom);
|
|
2962
|
+
if (property === undefined) {
|
|
2963
|
+
return isComputedValue(value);
|
|
2962
2964
|
}
|
|
2963
2965
|
|
|
2964
|
-
|
|
2966
|
+
if (isObservableObject(value) === false) return false;
|
|
2967
|
+
if (!value[$mobx].values_.has(property)) return false;
|
|
2968
|
+
var atom = getAtom(value, property);
|
|
2969
|
+
return isComputedValue(atom);
|
|
2965
2970
|
}
|
|
2966
2971
|
function isComputed(value) {
|
|
2967
2972
|
if ( arguments.length > 1) return die("isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property");
|
|
@@ -3285,10 +3290,10 @@ function _when(predicate, effect, opts) {
|
|
|
3285
3290
|
var timeoutHandle;
|
|
3286
3291
|
|
|
3287
3292
|
if (typeof opts.timeout === "number") {
|
|
3293
|
+
var error = new Error("WHEN_TIMEOUT");
|
|
3288
3294
|
timeoutHandle = setTimeout(function () {
|
|
3289
3295
|
if (!disposer[$mobx].isDisposed_) {
|
|
3290
3296
|
disposer();
|
|
3291
|
-
var error = new Error("WHEN_TIMEOUT");
|
|
3292
3297
|
if (opts.onError) opts.onError(error);else throw error;
|
|
3293
3298
|
}
|
|
3294
3299
|
}, opts.timeout);
|
|
@@ -3320,7 +3325,7 @@ function whenPromise(predicate, opts) {
|
|
|
3320
3325
|
|
|
3321
3326
|
cancel = function cancel() {
|
|
3322
3327
|
disposer();
|
|
3323
|
-
reject("WHEN_CANCELLED");
|
|
3328
|
+
reject(new Error("WHEN_CANCELLED"));
|
|
3324
3329
|
};
|
|
3325
3330
|
});
|
|
3326
3331
|
res.cancel = cancel;
|
|
@@ -3451,7 +3456,11 @@ function makeObservable(target, annotations, options) {
|
|
|
3451
3456
|
try {
|
|
3452
3457
|
var _annotations;
|
|
3453
3458
|
|
|
3454
|
-
|
|
3459
|
+
if ("development" !== "production" && annotations && target[storedAnnotationsSymbol]) {
|
|
3460
|
+
die("makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported.");
|
|
3461
|
+
} // Default to decorators
|
|
3462
|
+
|
|
3463
|
+
|
|
3455
3464
|
(_annotations = annotations) != null ? _annotations : annotations = collectStoredAnnotations(target); // Annotate
|
|
3456
3465
|
|
|
3457
3466
|
ownKeys(annotations).forEach(function (key) {
|
|
@@ -3612,7 +3621,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3612
3621
|
};
|
|
3613
3622
|
|
|
3614
3623
|
_proto.setArrayLength_ = function setArrayLength_(newLength) {
|
|
3615
|
-
if (typeof newLength !== "number" || newLength < 0) die("Out of range: " + newLength);
|
|
3624
|
+
if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) die("Out of range: " + newLength);
|
|
3616
3625
|
var currentLength = this.values_.length;
|
|
3617
3626
|
if (newLength === currentLength) return;else if (newLength > currentLength) {
|
|
3618
3627
|
var newItems = new Array(newLength - currentLength);
|
|
@@ -4101,9 +4110,11 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4101
4110
|
|
|
4102
4111
|
if ( notifySpy) spyReportStart(_change);
|
|
4103
4112
|
transaction(function () {
|
|
4113
|
+
var _this2$hasMap_$get;
|
|
4114
|
+
|
|
4104
4115
|
_this2.keysAtom_.reportChanged();
|
|
4105
4116
|
|
|
4106
|
-
_this2.
|
|
4117
|
+
(_this2$hasMap_$get = _this2.hasMap_.get(key)) == null ? void 0 : _this2$hasMap_$get.setNewValue_(false);
|
|
4107
4118
|
|
|
4108
4119
|
var observable = _this2.data_.get(key);
|
|
4109
4120
|
|
|
@@ -4119,14 +4130,6 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4119
4130
|
return false;
|
|
4120
4131
|
};
|
|
4121
4132
|
|
|
4122
|
-
_proto.updateHasMapEntry_ = function updateHasMapEntry_(key, value) {
|
|
4123
|
-
var entry = this.hasMap_.get(key);
|
|
4124
|
-
|
|
4125
|
-
if (entry) {
|
|
4126
|
-
entry.setNewValue_(value);
|
|
4127
|
-
}
|
|
4128
|
-
};
|
|
4129
|
-
|
|
4130
4133
|
_proto.updateValue_ = function updateValue_(key, newValue) {
|
|
4131
4134
|
var observable = this.data_.get(key);
|
|
4132
4135
|
newValue = observable.prepareNewValue_(newValue);
|
|
@@ -4155,13 +4158,15 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4155
4158
|
|
|
4156
4159
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4157
4160
|
transaction(function () {
|
|
4161
|
+
var _this3$hasMap_$get;
|
|
4162
|
+
|
|
4158
4163
|
var observable = new ObservableValue(newValue, _this3.enhancer_, _this3.name_ + "." + stringifyKey(key) , false);
|
|
4159
4164
|
|
|
4160
4165
|
_this3.data_.set(key, observable);
|
|
4161
4166
|
|
|
4162
4167
|
newValue = observable.value_; // value might have been changed
|
|
4163
4168
|
|
|
4164
|
-
_this3.
|
|
4169
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(true);
|
|
4165
4170
|
|
|
4166
4171
|
_this3.keysAtom_.reportChanged();
|
|
4167
4172
|
});
|
|
@@ -5738,7 +5743,7 @@ function isAnnotation(thing) {
|
|
|
5738
5743
|
* - utils/ Utility stuff.
|
|
5739
5744
|
*
|
|
5740
5745
|
*/
|
|
5741
|
-
["Symbol", "Map", "Set"
|
|
5746
|
+
["Symbol", "Map", "Set"].forEach(function (m) {
|
|
5742
5747
|
var g = getGlobal();
|
|
5743
5748
|
|
|
5744
5749
|
if (typeof g[m] === "undefined") {
|