mobx 6.3.11 → 6.3.12

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
@@ -4029,6 +4029,8 @@ _Symbol$toStringTag = Symbol.toStringTag;
4029
4029
  var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4030
4030
  // hasMap, not hashMap >-).
4031
4031
  function ObservableMap(initialData, enhancer_, name_) {
4032
+ var _this = this;
4033
+
4032
4034
  if (enhancer_ === void 0) {
4033
4035
  enhancer_ = deepEnhancer;
4034
4036
  }
@@ -4056,7 +4058,9 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4056
4058
  this.keysAtom_ = createAtom(process.env.NODE_ENV !== "production" ? this.name_ + ".keys()" : "ObservableMap.keys()");
4057
4059
  this.data_ = new Map();
4058
4060
  this.hasMap_ = new Map();
4059
- this.merge(initialData);
4061
+ allowStateChanges(true, function () {
4062
+ _this.merge(initialData);
4063
+ });
4060
4064
  }
4061
4065
 
4062
4066
  var _proto = ObservableMap.prototype;
@@ -4066,7 +4070,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4066
4070
  };
4067
4071
 
4068
4072
  _proto.has = function has(key) {
4069
- var _this = this;
4073
+ var _this2 = this;
4070
4074
 
4071
4075
  if (!globalState.trackingDerivation) return this.has_(key);
4072
4076
  var entry = this.hasMap_.get(key);
@@ -4075,7 +4079,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4075
4079
  var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, process.env.NODE_ENV !== "production" ? this.name_ + "." + stringifyKey(key) + "?" : "ObservableMap.key?", false);
4076
4080
  this.hasMap_.set(key, newEntry);
4077
4081
  onBecomeUnobserved(newEntry, function () {
4078
- return _this.hasMap_["delete"](key);
4082
+ return _this2.hasMap_["delete"](key);
4079
4083
  });
4080
4084
  }
4081
4085
 
@@ -4106,7 +4110,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4106
4110
  };
4107
4111
 
4108
4112
  _proto["delete"] = function _delete(key) {
4109
- var _this2 = this;
4113
+ var _this3 = this;
4110
4114
 
4111
4115
  checkIfStateModificationsAreAllowed(this.keysAtom_);
4112
4116
 
@@ -4135,17 +4139,17 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4135
4139
  if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(_change); // TODO fix type
4136
4140
 
4137
4141
  transaction(function () {
4138
- var _this2$hasMap_$get;
4142
+ var _this3$hasMap_$get;
4139
4143
 
4140
- _this2.keysAtom_.reportChanged();
4144
+ _this3.keysAtom_.reportChanged();
4141
4145
 
4142
- (_this2$hasMap_$get = _this2.hasMap_.get(key)) == null ? void 0 : _this2$hasMap_$get.setNewValue_(false);
4146
+ (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
4143
4147
 
4144
- var observable = _this2.data_.get(key);
4148
+ var observable = _this3.data_.get(key);
4145
4149
 
4146
4150
  observable.setNewValue_(undefined);
4147
4151
 
4148
- _this2.data_["delete"](key);
4152
+ _this3.data_["delete"](key);
4149
4153
  });
4150
4154
  if (notify) notifyListeners(this, _change);
4151
4155
  if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
@@ -4180,21 +4184,21 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4180
4184
  };
4181
4185
 
4182
4186
  _proto.addValue_ = function addValue_(key, newValue) {
4183
- var _this3 = this;
4187
+ var _this4 = this;
4184
4188
 
4185
4189
  checkIfStateModificationsAreAllowed(this.keysAtom_);
4186
4190
  transaction(function () {
4187
- var _this3$hasMap_$get;
4191
+ var _this4$hasMap_$get;
4188
4192
 
4189
- var observable = new ObservableValue(newValue, _this3.enhancer_, process.env.NODE_ENV !== "production" ? _this3.name_ + "." + stringifyKey(key) : "ObservableMap.key", false);
4193
+ var observable = new ObservableValue(newValue, _this4.enhancer_, process.env.NODE_ENV !== "production" ? _this4.name_ + "." + stringifyKey(key) : "ObservableMap.key", false);
4190
4194
 
4191
- _this3.data_.set(key, observable);
4195
+ _this4.data_.set(key, observable);
4192
4196
 
4193
4197
  newValue = observable.value_; // value might have been changed
4194
4198
 
4195
- (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(true);
4199
+ (_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
4196
4200
 
4197
- _this3.keysAtom_.reportChanged();
4201
+ _this4.keysAtom_.reportChanged();
4198
4202
  });
4199
4203
  var notifySpy = isSpyEnabled();
4200
4204
  var notify = hasListeners(this);
@@ -4280,7 +4284,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4280
4284
  ;
4281
4285
 
4282
4286
  _proto.merge = function merge(other) {
4283
- var _this4 = this;
4287
+ var _this5 = this;
4284
4288
 
4285
4289
  if (isObservableMap(other)) {
4286
4290
  other = new Map(other);
@@ -4288,15 +4292,15 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4288
4292
 
4289
4293
  transaction(function () {
4290
4294
  if (isPlainObject(other)) getPlainObjectKeys(other).forEach(function (key) {
4291
- return _this4.set(key, other[key]);
4295
+ return _this5.set(key, other[key]);
4292
4296
  });else if (Array.isArray(other)) other.forEach(function (_ref) {
4293
4297
  var key = _ref[0],
4294
4298
  value = _ref[1];
4295
- return _this4.set(key, value);
4299
+ return _this5.set(key, value);
4296
4300
  });else if (isES6Map(other)) {
4297
4301
  if (other.constructor !== Map) die(19, other);
4298
4302
  other.forEach(function (value, key) {
4299
- return _this4.set(key, value);
4303
+ return _this5.set(key, value);
4300
4304
  });
4301
4305
  } else if (other !== null && other !== undefined) die(20, other);
4302
4306
  });
@@ -4304,21 +4308,21 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4304
4308
  };
4305
4309
 
4306
4310
  _proto.clear = function clear() {
4307
- var _this5 = this;
4311
+ var _this6 = this;
4308
4312
 
4309
4313
  transaction(function () {
4310
4314
  untracked(function () {
4311
- for (var _iterator2 = _createForOfIteratorHelperLoose(_this5.keys()), _step2; !(_step2 = _iterator2()).done;) {
4315
+ for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done;) {
4312
4316
  var key = _step2.value;
4313
4317
 
4314
- _this5["delete"](key);
4318
+ _this6["delete"](key);
4315
4319
  }
4316
4320
  });
4317
4321
  });
4318
4322
  };
4319
4323
 
4320
4324
  _proto.replace = function replace(values) {
4321
- var _this6 = this;
4325
+ var _this7 = this;
4322
4326
 
4323
4327
  // Implementation requirements:
4324
4328
  // - respect ordering of replacement map
@@ -4335,13 +4339,13 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4335
4339
  // if the key deletion is prevented by interceptor
4336
4340
  // add entry at the beginning of the result map
4337
4341
 
4338
- for (var _iterator3 = _createForOfIteratorHelperLoose(_this6.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
4342
+ for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
4339
4343
  var key = _step3.value;
4340
4344
 
4341
4345
  // Concurrently iterating/deleting keys
4342
4346
  // iterator should handle this correctly
4343
4347
  if (!replacementMap.has(key)) {
4344
- var deleted = _this6["delete"](key); // Was the key removed?
4348
+ var deleted = _this7["delete"](key); // Was the key removed?
4345
4349
 
4346
4350
 
4347
4351
  if (deleted) {
@@ -4349,7 +4353,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4349
4353
  keysReportChangedCalled = true;
4350
4354
  } else {
4351
4355
  // Delete prevented by interceptor
4352
- var value = _this6.data_.get(key);
4356
+ var value = _this7.data_.get(key);
4353
4357
 
4354
4358
  orderedData.set(key, value);
4355
4359
  }
@@ -4363,17 +4367,17 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4363
4367
  _value = _step4$value[1];
4364
4368
 
4365
4369
  // We will want to know whether a new key is added
4366
- var keyExisted = _this6.data_.has(_key); // Add or update value
4370
+ var keyExisted = _this7.data_.has(_key); // Add or update value
4367
4371
 
4368
4372
 
4369
- _this6.set(_key, _value); // The addition could have been prevent by interceptor
4373
+ _this7.set(_key, _value); // The addition could have been prevent by interceptor
4370
4374
 
4371
4375
 
4372
- if (_this6.data_.has(_key)) {
4376
+ if (_this7.data_.has(_key)) {
4373
4377
  // The update could have been prevented by interceptor
4374
4378
  // and also we want to preserve existing values
4375
4379
  // so use value from _data map (instead of replacement map)
4376
- var _value2 = _this6.data_.get(_key);
4380
+ var _value2 = _this7.data_.get(_key);
4377
4381
 
4378
4382
  orderedData.set(_key, _value2); // Was a new key added?
4379
4383
 
@@ -4386,11 +4390,11 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4386
4390
 
4387
4391
 
4388
4392
  if (!keysReportChangedCalled) {
4389
- if (_this6.data_.size !== orderedData.size) {
4393
+ if (_this7.data_.size !== orderedData.size) {
4390
4394
  // If size differs, keys are definitely modified
4391
- _this6.keysAtom_.reportChanged();
4395
+ _this7.keysAtom_.reportChanged();
4392
4396
  } else {
4393
- var iter1 = _this6.data_.keys();
4397
+ var iter1 = _this7.data_.keys();
4394
4398
 
4395
4399
  var iter2 = orderedData.keys();
4396
4400
  var next1 = iter1.next();
@@ -4398,7 +4402,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4398
4402
 
4399
4403
  while (!next1.done) {
4400
4404
  if (next1.value !== next2.value) {
4401
- _this6.keysAtom_.reportChanged();
4405
+ _this7.keysAtom_.reportChanged();
4402
4406
 
4403
4407
  break;
4404
4408
  }
@@ -4410,7 +4414,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4410
4414
  } // Use correctly ordered map
4411
4415
 
4412
4416
 
4413
- _this6.data_ = orderedData;
4417
+ _this7.data_ = orderedData;
4414
4418
  });
4415
4419
  return this;
4416
4420
  };