mobx 6.3.2 → 6.3.3
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 +17 -0
- package/README.md +3 -3
- package/dist/api/autorun.d.ts +3 -3
- package/dist/mobx.cjs.development.js +21 -16
- 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 +21 -16
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +21 -16
- 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 +21 -16
- 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 +5 -5
- package/src/api/observable.ts +4 -4
- package/src/api/when.ts +1 -1
- package/src/core/computedvalue.ts +8 -6
- package/src/core/derivation.ts +4 -2
- package/src/mobx.ts +1 -1
- package/src/utils/comparer.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# mobx
|
|
2
2
|
|
|
3
|
+
## 6.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`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
|
|
8
|
+
|
|
9
|
+
* [`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
|
|
10
|
+
`requiresReaction` warns instead of throwing
|
|
11
|
+
|
|
12
|
+
- [`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
|
|
13
|
+
|
|
14
|
+
* [`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
|
|
15
|
+
|
|
16
|
+
- [`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
|
|
17
|
+
|
|
18
|
+
* [`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
|
|
19
|
+
|
|
3
20
|
## 6.3.2
|
|
4
21
|
|
|
5
22
|
### 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>
|
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 & {
|
|
20
|
+
export declare type IReactionOptions<T> = IAutorunOptions & {
|
|
21
21
|
fireImmediately?: boolean;
|
|
22
|
-
equals?: IEqualsComparer<
|
|
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>(expression: (r: IReactionPublic) => T, effect: (arg: T, prev: T, r: IReactionPublic) => void, opts?: IReactionOptions<T>): 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 = {
|
|
@@ -959,6 +960,10 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
|
959
960
|
return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
|
|
960
961
|
}
|
|
961
962
|
|
|
963
|
+
var OBSERVABLE = "observable";
|
|
964
|
+
var OBSERVABLE_REF = "observable.ref";
|
|
965
|
+
var OBSERVABLE_SHALLOW = "observable.shallow";
|
|
966
|
+
var OBSERVABLE_STRUCT = "observable.struct"; // Predefined bags of create observable options, to avoid allocating temporarily option objects
|
|
962
967
|
// in the majority of cases
|
|
963
968
|
|
|
964
969
|
var defaultCreateObservableOptions = {
|
|
@@ -971,14 +976,14 @@ Object.freeze(defaultCreateObservableOptions);
|
|
|
971
976
|
function asCreateObservableOptions(thing) {
|
|
972
977
|
return thing || defaultCreateObservableOptions;
|
|
973
978
|
}
|
|
974
|
-
var observableAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
975
|
-
var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
979
|
+
var observableAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE);
|
|
980
|
+
var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_REF, {
|
|
976
981
|
enhancer: referenceEnhancer
|
|
977
982
|
});
|
|
978
|
-
var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
983
|
+
var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_SHALLOW, {
|
|
979
984
|
enhancer: shallowEnhancer
|
|
980
985
|
});
|
|
981
|
-
var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
986
|
+
var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_STRUCT, {
|
|
982
987
|
enhancer: refStructEnhancer
|
|
983
988
|
});
|
|
984
989
|
var observableDecoratorAnnotation = /*#__PURE__*/createDecoratorAnnotation(observableAnnotation);
|
|
@@ -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
|
/**
|
|
@@ -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);
|
|
@@ -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") {
|