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
|
@@ -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:
|
|
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
|
-
|
|
2318
|
-
abortSignal
|
|
2319
|
-
|
|
2320
|
-
|
|
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 (
|
|
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.
|
|
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();
|