mobx 6.4.1 → 6.6.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # mobx
2
2
 
3
+ ## 6.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`8e204c7b`](https://github.com/mobxjs/mobx/commit/8e204c7b7d1dbad597761fa83beda77f027ee34c) [#3409](https://github.com/mobxjs/mobx/pull/3409) Thanks [@Nokel81](https://github.com/Nokel81)! - Remove observable.box type inconsistancy
8
+
9
+ ## 6.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`767baff0`](https://github.com/mobxjs/mobx/commit/767baff0373e5a5e2b7da274b25042078f9a205c) [#3338](https://github.com/mobxjs/mobx/pull/3338) Thanks [@kubk](https://github.com/kubk)! - Replace any with a generic in Set methods
14
+
15
+ ## 6.4.2
16
+
17
+ ### Patch Changes
18
+
19
+ - [`2caf7e1a`](https://github.com/mobxjs/mobx/commit/2caf7e1a3504dde3d7c9bde3c6fb56ca85168018) [#3316](https://github.com/mobxjs/mobx/pull/3316) Thanks [@urugator](https://github.com/urugator)! - `requiresObservable` always takes precedence over global `reactionRequiresObservable`
20
+
3
21
  ## 6.4.1
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -15,7 +15,7 @@ _Simple, scalable state management._
15
15
 
16
16
  > Documentation for older **unsupported** V4/V5 can be [found here](https://github.com/mobxjs/mobx/blob/mobx4and5/docs/README.md), but be sure to read about [current documentation first](https://mobx.js.org/about-this-documentation.html).
17
17
 
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.
18
+ 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.
19
19
 
20
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>
@@ -16,12 +16,16 @@ export declare function asCreateObservableOptions(thing: any): CreateObservableO
16
16
  export declare function getEnhancerFromOptions(options: CreateObservableOptions): IEnhancer<any>;
17
17
  export declare function getAnnotationFromOptions(options?: CreateObservableOptions): Annotation | undefined;
18
18
  export declare function getEnhancerFromAnnotation(annotation?: Annotation): IEnhancer<any>;
19
+ export interface IObservableValueFactory {
20
+ <T>(value: T, options?: CreateObservableOptions): IObservableValue<T>;
21
+ <T>(value?: T, options?: CreateObservableOptions): IObservableValue<T | undefined>;
22
+ }
19
23
  export interface IObservableFactory extends Annotation, PropertyDecorator {
20
24
  <T = any>(value: T[], options?: CreateObservableOptions): IObservableArray<T>;
21
25
  <T = any>(value: Set<T>, options?: CreateObservableOptions): ObservableSet<T>;
22
26
  <K = any, V = any>(value: Map<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
23
27
  <T extends object>(value: T, decorators?: AnnotationsMap<T, never>, options?: CreateObservableOptions): T;
24
- box: <T = any>(value?: T, options?: CreateObservableOptions) => IObservableValue<T>;
28
+ box: IObservableValueFactory;
25
29
  array: <T = any>(initialValues?: T[], options?: CreateObservableOptions) => IObservableArray<T>;
26
30
  set: <T = any>(initialValues?: IObservableSetInitialValues<T>, options?: CreateObservableOptions) => ObservableSet<T>;
27
31
  map: <K = any, V = any>(initialValues?: IObservableMapInitialValues<K, V>, options?: CreateObservableOptions) => ObservableMap<K, V>;
@@ -29,7 +29,7 @@ export declare class Reaction implements IDerivation, IReactionPublic {
29
29
  name_: string;
30
30
  private onInvalidate_;
31
31
  private errorHandler_?;
32
- requiresObservable_: boolean;
32
+ requiresObservable_?: any;
33
33
  observing_: IObservable[];
34
34
  newObserving_: IObservable[];
35
35
  dependenciesState_: IDerivationState_;
@@ -41,7 +41,7 @@ export declare class Reaction implements IDerivation, IReactionPublic {
41
41
  isTrackPending_: boolean;
42
42
  isRunning_: boolean;
43
43
  isTracing_: TraceMode;
44
- constructor(name_: string, onInvalidate_: () => void, errorHandler_?: ((error: any, derivation: IDerivation) => void) | undefined, requiresObservable_?: boolean);
44
+ constructor(name_: string, onInvalidate_: () => void, errorHandler_?: ((error: any, derivation: IDerivation) => void) | undefined, requiresObservable_?: any);
45
45
  onBecomeStale_(): void;
46
46
  schedule_(): void;
47
47
  isScheduled(): boolean;
@@ -1350,7 +1350,7 @@ function allowStateChangesEnd(prev) {
1350
1350
  var _Symbol$toPrimitive;
1351
1351
  var CREATE = "create";
1352
1352
  _Symbol$toPrimitive = Symbol.toPrimitive;
1353
- var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1353
+ var ObservableValue = /*#__PURE__*/function (_Atom) {
1354
1354
  _inheritsLoose(ObservableValue, _Atom);
1355
1355
 
1356
1356
  function ObservableValue(value, enhancer, name_, notifySpy, equals) {
@@ -1510,12 +1510,12 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1510
1510
  return toPrimitive(this.get());
1511
1511
  };
1512
1512
 
1513
- _proto[_Symbol$toPrimitive2] = function () {
1513
+ _proto[_Symbol$toPrimitive] = function () {
1514
1514
  return this.valueOf();
1515
1515
  };
1516
1516
 
1517
1517
  return ObservableValue;
1518
- }(Atom, _Symbol$toPrimitive);
1518
+ }(Atom);
1519
1519
  var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
1520
1520
 
1521
1521
  var _Symbol$toPrimitive$1;
@@ -1540,7 +1540,7 @@ var _Symbol$toPrimitive$1;
1540
1540
  */
1541
1541
 
1542
1542
  _Symbol$toPrimitive$1 = Symbol.toPrimitive;
1543
- var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1543
+ var ComputedValue = /*#__PURE__*/function () {
1544
1544
  // nodes we are looking at. Our value depends on these nodes
1545
1545
  // during tracking it's an array with new observed observers
1546
1546
  // to check for cycles
@@ -1797,12 +1797,12 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1797
1797
  return toPrimitive(this.get());
1798
1798
  };
1799
1799
 
1800
- _proto[_Symbol$toPrimitive2] = function () {
1800
+ _proto[_Symbol$toPrimitive$1] = function () {
1801
1801
  return this.valueOf();
1802
1802
  };
1803
1803
 
1804
1804
  return ComputedValue;
1805
- }(_Symbol$toPrimitive$1);
1805
+ }();
1806
1806
  var isComputedValue = /*#__PURE__*/createInstanceofPredicate("ComputedValue", ComputedValue);
1807
1807
 
1808
1808
  var IDerivationState_;
@@ -1966,7 +1966,7 @@ function warnAboutDerivationWithoutDependencies(derivation) {
1966
1966
  return;
1967
1967
  }
1968
1968
 
1969
- if (globalState.reactionRequiresObservable || derivation.requiresObservable_) {
1969
+ if (typeof derivation.requiresObservable_ === "boolean" ? derivation.requiresObservable_ : globalState.reactionRequiresObservable) {
1970
1970
  console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
1971
1971
  }
1972
1972
  }
@@ -2437,10 +2437,6 @@ var Reaction = /*#__PURE__*/function () {
2437
2437
  name_ = "Reaction@" + getNextId() ;
2438
2438
  }
2439
2439
 
2440
- if (requiresObservable_ === void 0) {
2441
- requiresObservable_ = false;
2442
- }
2443
-
2444
2440
  this.name_ = void 0;
2445
2441
  this.onInvalidate_ = void 0;
2446
2442
  this.errorHandler_ = void 0;
@@ -4486,7 +4482,7 @@ var DELETE = "delete"; // just extend Map? See also https://gist.github.com/nest
4486
4482
 
4487
4483
  _Symbol$iterator = Symbol.iterator;
4488
4484
  _Symbol$toStringTag = Symbol.toStringTag;
4489
- var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4485
+ var ObservableMap = /*#__PURE__*/function () {
4490
4486
  // hasMap, not hashMap >-).
4491
4487
  function ObservableMap(initialData, enhancer_, name_) {
4492
4488
  var _this = this;
@@ -4770,7 +4766,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4770
4766
  });
4771
4767
  };
4772
4768
 
4773
- _proto[_Symbol$iterator2] = function () {
4769
+ _proto[_Symbol$iterator] = function () {
4774
4770
  return this.entries();
4775
4771
  };
4776
4772
 
@@ -4962,14 +4958,14 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4962
4958
  return this.data_.size;
4963
4959
  }
4964
4960
  }, {
4965
- key: _Symbol$toStringTag2,
4961
+ key: _Symbol$toStringTag,
4966
4962
  get: function get() {
4967
4963
  return "Map";
4968
4964
  }
4969
4965
  }]);
4970
4966
 
4971
4967
  return ObservableMap;
4972
- }(_Symbol$iterator, _Symbol$toStringTag); // eslint-disable-next-line
4968
+ }(); // eslint-disable-next-line
4973
4969
 
4974
4970
  var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
4975
4971
 
@@ -4995,7 +4991,7 @@ var _Symbol$iterator$1, _Symbol$toStringTag$1;
4995
4991
  var ObservableSetMarker = {};
4996
4992
  _Symbol$iterator$1 = Symbol.iterator;
4997
4993
  _Symbol$toStringTag$1 = Symbol.toStringTag;
4998
- var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4994
+ var ObservableSet = /*#__PURE__*/function () {
4999
4995
  function ObservableSet(initialData, enhancer, name_) {
5000
4996
  if (enhancer === void 0) {
5001
4997
  enhancer = deepEnhancer;
@@ -5256,7 +5252,7 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
5256
5252
  return "[object ObservableSet]";
5257
5253
  };
5258
5254
 
5259
- _proto[_Symbol$iterator2] = function () {
5255
+ _proto[_Symbol$iterator$1] = function () {
5260
5256
  return this.values();
5261
5257
  };
5262
5258
 
@@ -5267,14 +5263,14 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
5267
5263
  return this.data_.size;
5268
5264
  }
5269
5265
  }, {
5270
- key: _Symbol$toStringTag2,
5266
+ key: _Symbol$toStringTag$1,
5271
5267
  get: function get() {
5272
5268
  return "Set";
5273
5269
  }
5274
5270
  }]);
5275
5271
 
5276
5272
  return ObservableSet;
5277
- }(_Symbol$iterator$1, _Symbol$toStringTag$1); // eslint-disable-next-line
5273
+ }(); // eslint-disable-next-line
5278
5274
 
5279
5275
  var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
5280
5276
 
@@ -6435,7 +6431,7 @@ function isAnnotation(thing) {
6435
6431
  * (c) Michel Weststrate 2015 - 2020
6436
6432
  * MIT Licensed
6437
6433
  *
6438
- * Welcome to the mobx sources! To get an global overview of how MobX internally works,
6434
+ * Welcome to the mobx sources! To get a global overview of how MobX internally works,
6439
6435
  * this is a good place to start:
6440
6436
  * https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
6441
6437
  *