mobx 7.0.5 → 7.0.6

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.
@@ -1197,14 +1197,13 @@
1197
1197
  this.equals_ = equals_;
1198
1198
  this.value_ = enhancer_(value, undefined, name_);
1199
1199
  if (notifySpy && isSpyEnabled()) {
1200
- var _this$value_;
1201
1200
  // only notify spy if this is a stand-alone observable
1202
1201
  spyReport({
1203
1202
  type: CREATE,
1204
1203
  object: this,
1205
1204
  observableKind: "value",
1206
1205
  debugObjectName: this.name_,
1207
- newValue: "" + ((_this$value_ = this.value_) == null ? void 0 : _this$value_.toString())
1206
+ newValue: this.value_
1208
1207
  });
1209
1208
  }
1210
1209
  }
@@ -2167,6 +2166,7 @@
2167
2166
  this.runId_ = 0;
2168
2167
  this.unboundDepsCount_ = 0;
2169
2168
  this.flags_ = 0b00000;
2169
+ this.removeAbortListener_ = undefined;
2170
2170
  this.name_ = name_;
2171
2171
  this.onInvalidate_ = onInvalidate_;
2172
2172
  this.errorHandler_ = errorHandler_;
@@ -2303,7 +2303,10 @@
2303
2303
  }
2304
2304
  dispose() {
2305
2305
  if (!this.isDisposed) {
2306
+ var _this$removeAbortList;
2306
2307
  this.isDisposed = true;
2308
+ // also covers self-disposal (`r.dispose()`, `when`), which bypasses the disposer
2309
+ (_this$removeAbortList = this.removeAbortListener_) == null || _this$removeAbortList.call(this);
2307
2310
  if (!this.isRunning) {
2308
2311
  // if disposed while running, clean up later. Maybe not optimal, but rare case
2309
2312
  startBatch();
@@ -2313,11 +2316,11 @@
2313
2316
  }
2314
2317
  }
2315
2318
  getDisposer_(abortSignal) {
2316
- const dispose = () => {
2317
- this.dispose();
2318
- abortSignal == null || abortSignal.removeEventListener == null || abortSignal.removeEventListener("abort", dispose);
2319
- };
2320
- abortSignal == null || abortSignal.addEventListener == null || abortSignal.addEventListener("abort", dispose);
2319
+ const dispose = () => this.dispose();
2320
+ if (abortSignal != null && abortSignal.addEventListener && !this.isDisposed) {
2321
+ abortSignal.addEventListener("abort", dispose);
2322
+ this.removeAbortListener_ = () => abortSignal.removeEventListener == null ? void 0 : abortSignal.removeEventListener("abort", dispose);
2323
+ }
2321
2324
  dispose[$mobx] = this;
2322
2325
  if ("dispose" in Symbol && typeof Symbol.dispose === "symbol") {
2323
2326
  dispose[Symbol.dispose] = dispose;
@@ -3474,8 +3477,7 @@
3474
3477
  const adm = target[$mobx];
3475
3478
  if (name === "length") {
3476
3479
  adm.setArrayLength_(value);
3477
- }
3478
- if (typeof name === "symbol" || isNaN(name)) {
3480
+ } else if (typeof name === "symbol" || isNaN(name)) {
3479
3481
  target[name] = value;
3480
3482
  } else {
3481
3483
  // numeric string
@@ -3520,7 +3522,7 @@
3520
3522
  return this.values_.length;
3521
3523
  }
3522
3524
  setArrayLength_(newLength) {
3523
- if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) {
3525
+ if (!Number.isInteger(newLength) || newLength < 0) {
3524
3526
  die(40, newLength);
3525
3527
  }
3526
3528
  let currentLength = this.values_.length;
@@ -4302,7 +4304,8 @@
4302
4304
  }
4303
4305
  if (!this.has(value)) {
4304
4306
  transaction(() => {
4305
- this.data_.add(this.enhancer_(value, undefined));
4307
+ value = this.enhancer_(value, undefined); // report the stored value, like map and array
4308
+ this.data_.add(value);
4306
4309
  this.atom_.reportChanged();
4307
4310
  });
4308
4311
  const notifySpy = isSpyEnabled();