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.
- package/CHANGELOG.md +12 -0
- package/dist/core/reaction.d.ts +1 -0
- package/dist/mobx.cjs.development.js +14 -11
- package/dist/mobx.cjs.development.js.map +1 -1
- package/dist/mobx.cjs.production.min.js +1 -1
- package/dist/mobx.cjs.production.min.js.map +1 -1
- package/dist/mobx.esm.development.js +14 -11
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +14 -11
- package/dist/mobx.esm.js.map +1 -1
- package/dist/mobx.esm.production.min.js +1 -1
- package/dist/mobx.esm.production.min.js.map +1 -1
- package/dist/mobx.mjs +14 -11
- package/dist/mobx.mjs.map +1 -1
- package/dist/mobx.umd.development.js +14 -11
- package/dist/mobx.umd.development.js.map +1 -1
- package/dist/mobx.umd.production.min.js +1 -1
- package/dist/mobx.umd.production.min.js.map +1 -1
- package/package.json +1 -1
- package/src/core/reaction.ts +8 -5
- package/src/types/observablearray.ts +2 -3
- package/src/types/observableset.ts +2 -1
- package/src/types/observablevalue.ts +1 -1
|
@@ -1191,14 +1191,13 @@ class ObservableValue extends Atom {
|
|
|
1191
1191
|
this.equals_ = equals_;
|
|
1192
1192
|
this.value_ = enhancer_(value, undefined, name_);
|
|
1193
1193
|
if (notifySpy && isSpyEnabled()) {
|
|
1194
|
-
var _this$value_;
|
|
1195
1194
|
// only notify spy if this is a stand-alone observable
|
|
1196
1195
|
spyReport({
|
|
1197
1196
|
type: CREATE,
|
|
1198
1197
|
object: this,
|
|
1199
1198
|
observableKind: "value",
|
|
1200
1199
|
debugObjectName: this.name_,
|
|
1201
|
-
newValue:
|
|
1200
|
+
newValue: this.value_
|
|
1202
1201
|
});
|
|
1203
1202
|
}
|
|
1204
1203
|
}
|
|
@@ -2161,6 +2160,7 @@ class Reaction {
|
|
|
2161
2160
|
this.runId_ = 0;
|
|
2162
2161
|
this.unboundDepsCount_ = 0;
|
|
2163
2162
|
this.flags_ = 0b00000;
|
|
2163
|
+
this.removeAbortListener_ = undefined;
|
|
2164
2164
|
this.name_ = name_;
|
|
2165
2165
|
this.onInvalidate_ = onInvalidate_;
|
|
2166
2166
|
this.errorHandler_ = errorHandler_;
|
|
@@ -2297,7 +2297,10 @@ class Reaction {
|
|
|
2297
2297
|
}
|
|
2298
2298
|
dispose() {
|
|
2299
2299
|
if (!this.isDisposed) {
|
|
2300
|
+
var _this$removeAbortList;
|
|
2300
2301
|
this.isDisposed = true;
|
|
2302
|
+
// also covers self-disposal (`r.dispose()`, `when`), which bypasses the disposer
|
|
2303
|
+
(_this$removeAbortList = this.removeAbortListener_) == null || _this$removeAbortList.call(this);
|
|
2301
2304
|
if (!this.isRunning) {
|
|
2302
2305
|
// if disposed while running, clean up later. Maybe not optimal, but rare case
|
|
2303
2306
|
startBatch();
|
|
@@ -2307,11 +2310,11 @@ class Reaction {
|
|
|
2307
2310
|
}
|
|
2308
2311
|
}
|
|
2309
2312
|
getDisposer_(abortSignal) {
|
|
2310
|
-
const dispose = () =>
|
|
2311
|
-
|
|
2312
|
-
abortSignal
|
|
2313
|
-
|
|
2314
|
-
|
|
2313
|
+
const dispose = () => this.dispose();
|
|
2314
|
+
if (abortSignal != null && abortSignal.addEventListener && !this.isDisposed) {
|
|
2315
|
+
abortSignal.addEventListener("abort", dispose);
|
|
2316
|
+
this.removeAbortListener_ = () => abortSignal.removeEventListener == null ? void 0 : abortSignal.removeEventListener("abort", dispose);
|
|
2317
|
+
}
|
|
2315
2318
|
dispose[$mobx] = this;
|
|
2316
2319
|
if ("dispose" in Symbol && typeof Symbol.dispose === "symbol") {
|
|
2317
2320
|
dispose[Symbol.dispose] = dispose;
|
|
@@ -3468,8 +3471,7 @@ const arrayTraps = {
|
|
|
3468
3471
|
const adm = target[$mobx];
|
|
3469
3472
|
if (name === "length") {
|
|
3470
3473
|
adm.setArrayLength_(value);
|
|
3471
|
-
}
|
|
3472
|
-
if (typeof name === "symbol" || isNaN(name)) {
|
|
3474
|
+
} else if (typeof name === "symbol" || isNaN(name)) {
|
|
3473
3475
|
target[name] = value;
|
|
3474
3476
|
} else {
|
|
3475
3477
|
// numeric string
|
|
@@ -3514,7 +3516,7 @@ class ObservableArrayAdministration {
|
|
|
3514
3516
|
return this.values_.length;
|
|
3515
3517
|
}
|
|
3516
3518
|
setArrayLength_(newLength) {
|
|
3517
|
-
if (
|
|
3519
|
+
if (!Number.isInteger(newLength) || newLength < 0) {
|
|
3518
3520
|
die(40, newLength);
|
|
3519
3521
|
}
|
|
3520
3522
|
let currentLength = this.values_.length;
|
|
@@ -4296,7 +4298,8 @@ class ObservableSet {
|
|
|
4296
4298
|
}
|
|
4297
4299
|
if (!this.has(value)) {
|
|
4298
4300
|
transaction(() => {
|
|
4299
|
-
this.
|
|
4301
|
+
value = this.enhancer_(value, undefined); // report the stored value, like map and array
|
|
4302
|
+
this.data_.add(value);
|
|
4300
4303
|
this.atom_.reportChanged();
|
|
4301
4304
|
});
|
|
4302
4305
|
const notifySpy = isSpyEnabled();
|