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.
@@ -4021,6 +4021,8 @@
4021
4021
  var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4022
4022
  // hasMap, not hashMap >-).
4023
4023
  function ObservableMap(initialData, enhancer_, name_) {
4024
+ var _this = this;
4025
+
4024
4026
  if (enhancer_ === void 0) {
4025
4027
  enhancer_ = deepEnhancer;
4026
4028
  }
@@ -4048,7 +4050,9 @@
4048
4050
  this.keysAtom_ = createAtom( this.name_ + ".keys()" );
4049
4051
  this.data_ = new Map();
4050
4052
  this.hasMap_ = new Map();
4051
- this.merge(initialData);
4053
+ allowStateChanges(true, function () {
4054
+ _this.merge(initialData);
4055
+ });
4052
4056
  }
4053
4057
 
4054
4058
  var _proto = ObservableMap.prototype;
@@ -4058,7 +4062,7 @@
4058
4062
  };
4059
4063
 
4060
4064
  _proto.has = function has(key) {
4061
- var _this = this;
4065
+ var _this2 = this;
4062
4066
 
4063
4067
  if (!globalState.trackingDerivation) return this.has_(key);
4064
4068
  var entry = this.hasMap_.get(key);
@@ -4067,7 +4071,7 @@
4067
4071
  var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?" , false);
4068
4072
  this.hasMap_.set(key, newEntry);
4069
4073
  onBecomeUnobserved(newEntry, function () {
4070
- return _this.hasMap_["delete"](key);
4074
+ return _this2.hasMap_["delete"](key);
4071
4075
  });
4072
4076
  }
4073
4077
 
@@ -4098,7 +4102,7 @@
4098
4102
  };
4099
4103
 
4100
4104
  _proto["delete"] = function _delete(key) {
4101
- var _this2 = this;
4105
+ var _this3 = this;
4102
4106
 
4103
4107
  checkIfStateModificationsAreAllowed(this.keysAtom_);
4104
4108
 
@@ -4127,17 +4131,17 @@
4127
4131
  if ( notifySpy) spyReportStart(_change); // TODO fix type
4128
4132
 
4129
4133
  transaction(function () {
4130
- var _this2$hasMap_$get;
4134
+ var _this3$hasMap_$get;
4131
4135
 
4132
- _this2.keysAtom_.reportChanged();
4136
+ _this3.keysAtom_.reportChanged();
4133
4137
 
4134
- (_this2$hasMap_$get = _this2.hasMap_.get(key)) == null ? void 0 : _this2$hasMap_$get.setNewValue_(false);
4138
+ (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
4135
4139
 
4136
- var observable = _this2.data_.get(key);
4140
+ var observable = _this3.data_.get(key);
4137
4141
 
4138
4142
  observable.setNewValue_(undefined);
4139
4143
 
4140
- _this2.data_["delete"](key);
4144
+ _this3.data_["delete"](key);
4141
4145
  });
4142
4146
  if (notify) notifyListeners(this, _change);
4143
4147
  if ( notifySpy) spyReportEnd();
@@ -4172,21 +4176,21 @@
4172
4176
  };
4173
4177
 
4174
4178
  _proto.addValue_ = function addValue_(key, newValue) {
4175
- var _this3 = this;
4179
+ var _this4 = this;
4176
4180
 
4177
4181
  checkIfStateModificationsAreAllowed(this.keysAtom_);
4178
4182
  transaction(function () {
4179
- var _this3$hasMap_$get;
4183
+ var _this4$hasMap_$get;
4180
4184
 
4181
- var observable = new ObservableValue(newValue, _this3.enhancer_, _this3.name_ + "." + stringifyKey(key) , false);
4185
+ var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
4182
4186
 
4183
- _this3.data_.set(key, observable);
4187
+ _this4.data_.set(key, observable);
4184
4188
 
4185
4189
  newValue = observable.value_; // value might have been changed
4186
4190
 
4187
- (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(true);
4191
+ (_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
4188
4192
 
4189
- _this3.keysAtom_.reportChanged();
4193
+ _this4.keysAtom_.reportChanged();
4190
4194
  });
4191
4195
  var notifySpy = isSpyEnabled();
4192
4196
  var notify = hasListeners(this);
@@ -4272,7 +4276,7 @@
4272
4276
  ;
4273
4277
 
4274
4278
  _proto.merge = function merge(other) {
4275
- var _this4 = this;
4279
+ var _this5 = this;
4276
4280
 
4277
4281
  if (isObservableMap(other)) {
4278
4282
  other = new Map(other);
@@ -4280,15 +4284,15 @@
4280
4284
 
4281
4285
  transaction(function () {
4282
4286
  if (isPlainObject(other)) getPlainObjectKeys(other).forEach(function (key) {
4283
- return _this4.set(key, other[key]);
4287
+ return _this5.set(key, other[key]);
4284
4288
  });else if (Array.isArray(other)) other.forEach(function (_ref) {
4285
4289
  var key = _ref[0],
4286
4290
  value = _ref[1];
4287
- return _this4.set(key, value);
4291
+ return _this5.set(key, value);
4288
4292
  });else if (isES6Map(other)) {
4289
4293
  if (other.constructor !== Map) die(19, other);
4290
4294
  other.forEach(function (value, key) {
4291
- return _this4.set(key, value);
4295
+ return _this5.set(key, value);
4292
4296
  });
4293
4297
  } else if (other !== null && other !== undefined) die(20, other);
4294
4298
  });
@@ -4296,21 +4300,21 @@
4296
4300
  };
4297
4301
 
4298
4302
  _proto.clear = function clear() {
4299
- var _this5 = this;
4303
+ var _this6 = this;
4300
4304
 
4301
4305
  transaction(function () {
4302
4306
  untracked(function () {
4303
- for (var _iterator2 = _createForOfIteratorHelperLoose(_this5.keys()), _step2; !(_step2 = _iterator2()).done;) {
4307
+ for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done;) {
4304
4308
  var key = _step2.value;
4305
4309
 
4306
- _this5["delete"](key);
4310
+ _this6["delete"](key);
4307
4311
  }
4308
4312
  });
4309
4313
  });
4310
4314
  };
4311
4315
 
4312
4316
  _proto.replace = function replace(values) {
4313
- var _this6 = this;
4317
+ var _this7 = this;
4314
4318
 
4315
4319
  // Implementation requirements:
4316
4320
  // - respect ordering of replacement map
@@ -4327,13 +4331,13 @@
4327
4331
  // if the key deletion is prevented by interceptor
4328
4332
  // add entry at the beginning of the result map
4329
4333
 
4330
- for (var _iterator3 = _createForOfIteratorHelperLoose(_this6.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
4334
+ for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
4331
4335
  var key = _step3.value;
4332
4336
 
4333
4337
  // Concurrently iterating/deleting keys
4334
4338
  // iterator should handle this correctly
4335
4339
  if (!replacementMap.has(key)) {
4336
- var deleted = _this6["delete"](key); // Was the key removed?
4340
+ var deleted = _this7["delete"](key); // Was the key removed?
4337
4341
 
4338
4342
 
4339
4343
  if (deleted) {
@@ -4341,7 +4345,7 @@
4341
4345
  keysReportChangedCalled = true;
4342
4346
  } else {
4343
4347
  // Delete prevented by interceptor
4344
- var value = _this6.data_.get(key);
4348
+ var value = _this7.data_.get(key);
4345
4349
 
4346
4350
  orderedData.set(key, value);
4347
4351
  }
@@ -4355,17 +4359,17 @@
4355
4359
  _value = _step4$value[1];
4356
4360
 
4357
4361
  // We will want to know whether a new key is added
4358
- var keyExisted = _this6.data_.has(_key); // Add or update value
4362
+ var keyExisted = _this7.data_.has(_key); // Add or update value
4359
4363
 
4360
4364
 
4361
- _this6.set(_key, _value); // The addition could have been prevent by interceptor
4365
+ _this7.set(_key, _value); // The addition could have been prevent by interceptor
4362
4366
 
4363
4367
 
4364
- if (_this6.data_.has(_key)) {
4368
+ if (_this7.data_.has(_key)) {
4365
4369
  // The update could have been prevented by interceptor
4366
4370
  // and also we want to preserve existing values
4367
4371
  // so use value from _data map (instead of replacement map)
4368
- var _value2 = _this6.data_.get(_key);
4372
+ var _value2 = _this7.data_.get(_key);
4369
4373
 
4370
4374
  orderedData.set(_key, _value2); // Was a new key added?
4371
4375
 
@@ -4378,11 +4382,11 @@
4378
4382
 
4379
4383
 
4380
4384
  if (!keysReportChangedCalled) {
4381
- if (_this6.data_.size !== orderedData.size) {
4385
+ if (_this7.data_.size !== orderedData.size) {
4382
4386
  // If size differs, keys are definitely modified
4383
- _this6.keysAtom_.reportChanged();
4387
+ _this7.keysAtom_.reportChanged();
4384
4388
  } else {
4385
- var iter1 = _this6.data_.keys();
4389
+ var iter1 = _this7.data_.keys();
4386
4390
 
4387
4391
  var iter2 = orderedData.keys();
4388
4392
  var next1 = iter1.next();
@@ -4390,7 +4394,7 @@
4390
4394
 
4391
4395
  while (!next1.done) {
4392
4396
  if (next1.value !== next2.value) {
4393
- _this6.keysAtom_.reportChanged();
4397
+ _this7.keysAtom_.reportChanged();
4394
4398
 
4395
4399
  break;
4396
4400
  }
@@ -4402,7 +4406,7 @@
4402
4406
  } // Use correctly ordered map
4403
4407
 
4404
4408
 
4405
- _this6.data_ = orderedData;
4409
+ _this7.data_ = orderedData;
4406
4410
  });
4407
4411
  return this;
4408
4412
  };