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/dist/mobx.esm.js CHANGED
@@ -1823,10 +1823,12 @@ function checkIfStateReadsAreAllowed(observable) {
1823
1823
  */
1824
1824
  function trackDerivedFunction(derivation, f, context) {
1825
1825
  var prevAllowStateReads = allowStateReadsStart(true);
1826
- // pre allocate array allocation + room for variation in deps
1827
- // array will be trimmed by bindDependencies
1828
1826
  changeDependenciesStateTo0(derivation);
1829
- derivation.newObserving_ = new Array(derivation.observing_.length + 100);
1827
+ // Preallocate array; will be trimmed by bindDependencies.
1828
+ derivation.newObserving_ = new Array(
1829
+ // Reserve constant space for initial dependencies, dynamic space otherwise.
1830
+ // See https://github.com/mobxjs/mobx/pull/3833
1831
+ derivation.runId_ === 0 ? 100 : derivation.observing_.length);
1830
1832
  derivation.unboundDepsCount_ = 0;
1831
1833
  derivation.runId_ = ++globalState.runId;
1832
1834
  var prevTracking = globalState.trackingDerivation;
@@ -2682,7 +2684,6 @@ function reaction(expression, effect, opts) {
2682
2684
  var firstTime = true;
2683
2685
  var isScheduled = false;
2684
2686
  var value;
2685
- var oldValue;
2686
2687
  var equals = opts.compareStructural ? comparer.structural : opts.equals || comparer["default"];
2687
2688
  var r = new Reaction(name, function () {
2688
2689
  if (firstTime || runSync) {
@@ -2698,12 +2699,12 @@ function reaction(expression, effect, opts) {
2698
2699
  return;
2699
2700
  }
2700
2701
  var changed = false;
2702
+ var oldValue = value;
2701
2703
  r.track(function () {
2702
2704
  var nextValue = allowStateChanges(false, function () {
2703
2705
  return expression(r);
2704
2706
  });
2705
2707
  changed = firstTime || !equals(value, nextValue);
2706
- oldValue = value;
2707
2708
  value = nextValue;
2708
2709
  });
2709
2710
  if (firstTime && opts.fireImmediately) {
@@ -4013,7 +4014,7 @@ function simpleFunc(funcName) {
4013
4014
  return dehancedValues[funcName].apply(dehancedValues, arguments);
4014
4015
  };
4015
4016
  }
4016
- // Make sure callbacks recieve correct array arg #2326
4017
+ // Make sure callbacks receive correct array arg #2326
4017
4018
  function mapLikeFunc(funcName) {
4018
4019
  return function (callback, thisArg) {
4019
4020
  var _this2 = this;
@@ -4025,7 +4026,7 @@ function mapLikeFunc(funcName) {
4025
4026
  });
4026
4027
  };
4027
4028
  }
4028
- // Make sure callbacks recieve correct array arg #2326
4029
+ // Make sure callbacks receive correct array arg #2326
4029
4030
  function reduceLikeFunc(funcName) {
4030
4031
  return function () {
4031
4032
  var _this3 = this;
@@ -5358,7 +5359,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
5358
5359
  _this.spliceWithArray(0, 0, initialValues);
5359
5360
  }
5360
5361
  if (safariPrototypeSetterInheritanceBug) {
5361
- // Seems that Safari won't use numeric prototype setter untill any * numeric property is
5362
+ // Seems that Safari won't use numeric prototype setter until any * numeric property is
5362
5363
  // defined on the instance. After that it works fine, even if this property is deleted.
5363
5364
  Object.defineProperty(_assertThisInitialized(_this), "0", ENTRY_0);
5364
5365
  }