mobx 6.12.0 → 6.12.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # mobx
2
2
 
3
+ ## 6.12.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`61abc53f`](https://github.com/mobxjs/mobx/commit/61abc53ff10554d1d5ce3e85466f6beda4d63fa2) [#3852](https://github.com/mobxjs/mobx/pull/3852) Thanks [@mweststrate](https://github.com/mweststrate)! - Patched the release process, forcing release to get everything in pristine state.
8
+
9
+ * [`b28e0ebb`](https://github.com/mobxjs/mobx/commit/b28e0ebbfc9aa11293bc185216da92997e497fd3) [#3816](https://github.com/mobxjs/mobx/pull/3816) Thanks [@barroij](https://github.com/barroij)! - Fix `IReactionDisposer` and `IIsObservableObject` interface definition so that Typescript knows the property key `$mobx` is a symbol and not a string
10
+
11
+ ## 6.12.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`620f78c7`](https://github.com/mobxjs/mobx/commit/620f78c74e66bc532a96e28b26fd2d0ed1b67d54) [#3812](https://github.com/mobxjs/mobx/pull/3812) Thanks [@barroij](https://github.com/barroij)! - Prevent `reaction` from heeping a Reference to the OldValue that would prevent GC.
16
+
17
+ * [`6111b093`](https://github.com/mobxjs/mobx/commit/6111b0939d0d3c0d46dc325ba6bbd5f740a161d3) [#3833](https://github.com/mobxjs/mobx/pull/3833) Thanks [@realyze](https://github.com/realyze)! - Reduce memory overhead of tracking dependencies
18
+
3
19
  ## 6.12.0
4
20
 
5
21
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { IDerivation, IDerivationState_, IObservable, Lambda, TraceMode, GenericAbortSignal } from "../internal";
1
+ import { $mobx, IDerivation, IDerivationState_, IObservable, Lambda, TraceMode, GenericAbortSignal } from "../internal";
2
2
  /**
3
3
  * Reactions are a special kind of derivations. Several things distinguishes them from normal reactive computations
4
4
  *
@@ -23,7 +23,7 @@ export interface IReactionPublic {
23
23
  }
24
24
  export interface IReactionDisposer {
25
25
  (): void;
26
- $mobx: Reaction;
26
+ [$mobx]: Reaction;
27
27
  }
28
28
  export declare class Reaction implements IDerivation, IReactionPublic {
29
29
  name_: string;
@@ -1820,10 +1820,12 @@ function checkIfStateReadsAreAllowed(observable) {
1820
1820
  */
1821
1821
  function trackDerivedFunction(derivation, f, context) {
1822
1822
  var prevAllowStateReads = allowStateReadsStart(true);
1823
- // pre allocate array allocation + room for variation in deps
1824
- // array will be trimmed by bindDependencies
1825
1823
  changeDependenciesStateTo0(derivation);
1826
- derivation.newObserving_ = new Array(derivation.observing_.length + 100);
1824
+ // Preallocate array; will be trimmed by bindDependencies.
1825
+ derivation.newObserving_ = new Array(
1826
+ // Reserve constant space for initial dependencies, dynamic space otherwise.
1827
+ // See https://github.com/mobxjs/mobx/pull/3833
1828
+ derivation.runId_ === 0 ? 100 : derivation.observing_.length);
1827
1829
  derivation.unboundDepsCount_ = 0;
1828
1830
  derivation.runId_ = ++globalState.runId;
1829
1831
  var prevTracking = globalState.trackingDerivation;
@@ -2664,7 +2666,6 @@ function reaction(expression, effect, opts) {
2664
2666
  var firstTime = true;
2665
2667
  var isScheduled = false;
2666
2668
  var value;
2667
- var oldValue;
2668
2669
  var equals = opts.compareStructural ? comparer.structural : opts.equals || comparer["default"];
2669
2670
  var r = new Reaction(name, function () {
2670
2671
  if (firstTime || runSync) {
@@ -2680,12 +2681,12 @@ function reaction(expression, effect, opts) {
2680
2681
  return;
2681
2682
  }
2682
2683
  var changed = false;
2684
+ var oldValue = value;
2683
2685
  r.track(function () {
2684
2686
  var nextValue = allowStateChanges(false, function () {
2685
2687
  return expression(r);
2686
2688
  });
2687
2689
  changed = firstTime || !equals(value, nextValue);
2688
- oldValue = value;
2689
2690
  value = nextValue;
2690
2691
  });
2691
2692
  if (firstTime && opts.fireImmediately) {
@@ -3992,7 +3993,7 @@ function simpleFunc(funcName) {
3992
3993
  return dehancedValues[funcName].apply(dehancedValues, arguments);
3993
3994
  };
3994
3995
  }
3995
- // Make sure callbacks recieve correct array arg #2326
3996
+ // Make sure callbacks receive correct array arg #2326
3996
3997
  function mapLikeFunc(funcName) {
3997
3998
  return function (callback, thisArg) {
3998
3999
  var _this2 = this;
@@ -4004,7 +4005,7 @@ function mapLikeFunc(funcName) {
4004
4005
  });
4005
4006
  };
4006
4007
  }
4007
- // Make sure callbacks recieve correct array arg #2326
4008
+ // Make sure callbacks receive correct array arg #2326
4008
4009
  function reduceLikeFunc(funcName) {
4009
4010
  return function () {
4010
4011
  var _this3 = this;
@@ -5337,7 +5338,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
5337
5338
  _this.spliceWithArray(0, 0, initialValues);
5338
5339
  }
5339
5340
  if (safariPrototypeSetterInheritanceBug) {
5340
- // Seems that Safari won't use numeric prototype setter untill any * numeric property is
5341
+ // Seems that Safari won't use numeric prototype setter until any * numeric property is
5341
5342
  // defined on the instance. After that it works fine, even if this property is deleted.
5342
5343
  Object.defineProperty(_assertThisInitialized(_this), "0", ENTRY_0);
5343
5344
  }