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
package/dist/mobx.esm.js
CHANGED
|
@@ -1194,14 +1194,13 @@ class ObservableValue extends Atom {
|
|
|
1194
1194
|
this.equals_ = equals_;
|
|
1195
1195
|
this.value_ = enhancer_(value, undefined, name_);
|
|
1196
1196
|
if (__MOBX_DEV__ && notifySpy && isSpyEnabled()) {
|
|
1197
|
-
var _this$value_;
|
|
1198
1197
|
// only notify spy if this is a stand-alone observable
|
|
1199
1198
|
spyReport({
|
|
1200
1199
|
type: CREATE,
|
|
1201
1200
|
object: this,
|
|
1202
1201
|
observableKind: "value",
|
|
1203
1202
|
debugObjectName: this.name_,
|
|
1204
|
-
newValue:
|
|
1203
|
+
newValue: this.value_
|
|
1205
1204
|
});
|
|
1206
1205
|
}
|
|
1207
1206
|
}
|
|
@@ -2173,6 +2172,7 @@ class Reaction {
|
|
|
2173
2172
|
this.runId_ = 0;
|
|
2174
2173
|
this.unboundDepsCount_ = 0;
|
|
2175
2174
|
this.flags_ = 0b00000;
|
|
2175
|
+
this.removeAbortListener_ = undefined;
|
|
2176
2176
|
this.name_ = name_;
|
|
2177
2177
|
this.onInvalidate_ = onInvalidate_;
|
|
2178
2178
|
this.errorHandler_ = errorHandler_;
|
|
@@ -2309,7 +2309,10 @@ class Reaction {
|
|
|
2309
2309
|
}
|
|
2310
2310
|
dispose() {
|
|
2311
2311
|
if (!this.isDisposed) {
|
|
2312
|
+
var _this$removeAbortList;
|
|
2312
2313
|
this.isDisposed = true;
|
|
2314
|
+
// also covers self-disposal (`r.dispose()`, `when`), which bypasses the disposer
|
|
2315
|
+
(_this$removeAbortList = this.removeAbortListener_) == null || _this$removeAbortList.call(this);
|
|
2313
2316
|
if (!this.isRunning) {
|
|
2314
2317
|
// if disposed while running, clean up later. Maybe not optimal, but rare case
|
|
2315
2318
|
startBatch();
|
|
@@ -2319,11 +2322,11 @@ class Reaction {
|
|
|
2319
2322
|
}
|
|
2320
2323
|
}
|
|
2321
2324
|
getDisposer_(abortSignal) {
|
|
2322
|
-
const dispose = () =>
|
|
2323
|
-
|
|
2324
|
-
abortSignal
|
|
2325
|
-
|
|
2326
|
-
|
|
2325
|
+
const dispose = () => this.dispose();
|
|
2326
|
+
if (abortSignal != null && abortSignal.addEventListener && !this.isDisposed) {
|
|
2327
|
+
abortSignal.addEventListener("abort", dispose);
|
|
2328
|
+
this.removeAbortListener_ = () => abortSignal.removeEventListener == null ? void 0 : abortSignal.removeEventListener("abort", dispose);
|
|
2329
|
+
}
|
|
2327
2330
|
dispose[$mobx] = this;
|
|
2328
2331
|
if ("dispose" in Symbol && typeof Symbol.dispose === "symbol") {
|
|
2329
2332
|
dispose[Symbol.dispose] = dispose;
|
|
@@ -3492,8 +3495,7 @@ const arrayTraps = {
|
|
|
3492
3495
|
const adm = target[$mobx];
|
|
3493
3496
|
if (name === "length") {
|
|
3494
3497
|
adm.setArrayLength_(value);
|
|
3495
|
-
}
|
|
3496
|
-
if (typeof name === "symbol" || isNaN(name)) {
|
|
3498
|
+
} else if (typeof name === "symbol" || isNaN(name)) {
|
|
3497
3499
|
target[name] = value;
|
|
3498
3500
|
} else {
|
|
3499
3501
|
// numeric string
|
|
@@ -3538,7 +3540,7 @@ class ObservableArrayAdministration {
|
|
|
3538
3540
|
return this.values_.length;
|
|
3539
3541
|
}
|
|
3540
3542
|
setArrayLength_(newLength) {
|
|
3541
|
-
if (
|
|
3543
|
+
if (!Number.isInteger(newLength) || newLength < 0) {
|
|
3542
3544
|
die(40, newLength);
|
|
3543
3545
|
}
|
|
3544
3546
|
let currentLength = this.values_.length;
|
|
@@ -4320,7 +4322,8 @@ class ObservableSet {
|
|
|
4320
4322
|
}
|
|
4321
4323
|
if (!this.has(value)) {
|
|
4322
4324
|
transaction(() => {
|
|
4323
|
-
this.
|
|
4325
|
+
value = this.enhancer_(value, undefined); // report the stored value, like map and array
|
|
4326
|
+
this.data_.add(value);
|
|
4324
4327
|
this.atom_.reportChanged();
|
|
4325
4328
|
});
|
|
4326
4329
|
const notifySpy = __MOBX_DEV__ && isSpyEnabled();
|