mobx 6.9.1 → 6.10.0
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 +10 -0
- package/dist/api/autorun.d.ts +2 -1
- package/dist/api/makeObservable.d.ts +3 -2
- package/dist/api/when.d.ts +1 -8
- package/dist/core/reaction.d.ts +2 -2
- package/dist/internal.d.ts +1 -0
- package/dist/mobx.cjs.development.js +19 -10
- 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 +19 -10
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +19 -10
- 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.umd.development.js +19 -10
- 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/dist/types/generic-abort-signal.d.ts +6 -0
- package/package.json +1 -1
- package/src/api/autorun.ts +11 -5
- package/src/api/makeObservable.ts +4 -2
- package/src/api/when.ts +2 -9
- package/src/core/reaction.ts +10 -5
- package/src/internal.ts +1 -0
- package/src/types/generic-abort-signal.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# mobx
|
|
2
2
|
|
|
3
|
+
## 6.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`bebd5f05`](https://github.com/mobxjs/mobx/commit/bebd5f0507a109145f401c78630ed9d59e4a1101) [#3727](https://github.com/mobxjs/mobx/pull/3727) Thanks [@rluvaton](https://github.com/rluvaton)! - Added support for `signal` (AbortSignal) in `autorun`, `reaction` and sync `when` options to dispose them
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`55f78ddc`](https://github.com/mobxjs/mobx/commit/55f78ddc20e84f38a7aa88b99a51ad994e558241) [#3717](https://github.com/mobxjs/mobx/pull/3717) Thanks [@liucan233](https://github.com/liucan233)! - remove proxy option for makeObservable and makeAutoObservable
|
|
12
|
+
|
|
3
13
|
## 6.9.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/api/autorun.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IEqualsComparer, IReactionDisposer, IReactionPublic } from "../internal";
|
|
1
|
+
import { IEqualsComparer, IReactionDisposer, IReactionPublic, GenericAbortSignal } from "../internal";
|
|
2
2
|
export interface IAutorunOptions {
|
|
3
3
|
delay?: number;
|
|
4
4
|
name?: string;
|
|
@@ -9,6 +9,7 @@ export interface IAutorunOptions {
|
|
|
9
9
|
requiresObservable?: boolean;
|
|
10
10
|
scheduler?: (callback: () => void) => any;
|
|
11
11
|
onError?: (error: any) => void;
|
|
12
|
+
signal?: GenericAbortSignal;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* Creates a named reactive view and keeps it alive, so that the view is always
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AnnotationsMap, CreateObservableOptions } from "../internal";
|
|
2
2
|
declare type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
3
|
+
declare type MakeObservableOptions = Omit<CreateObservableOptions, "proxy">;
|
|
4
|
+
export declare function makeObservable<T extends object, AdditionalKeys extends PropertyKey = never>(target: T, annotations?: AnnotationsMap<T, NoInfer<AdditionalKeys>>, options?: MakeObservableOptions): T;
|
|
5
|
+
export declare function makeAutoObservable<T extends object, AdditionalKeys extends PropertyKey = never>(target: T, overrides?: AnnotationsMap<T, NoInfer<AdditionalKeys>>, options?: MakeObservableOptions): T;
|
|
5
6
|
export {};
|
package/dist/api/when.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import { IReactionDisposer, Lambda } from "../internal";
|
|
2
|
-
interface GenericAbortSignal {
|
|
3
|
-
readonly aborted: boolean;
|
|
4
|
-
onabort?: ((...args: any) => any) | null;
|
|
5
|
-
addEventListener?: (...args: any) => any;
|
|
6
|
-
removeEventListener?: (...args: any) => any;
|
|
7
|
-
}
|
|
1
|
+
import { IReactionDisposer, Lambda, GenericAbortSignal } from "../internal";
|
|
8
2
|
export interface IWhenOptions {
|
|
9
3
|
name?: string;
|
|
10
4
|
timeout?: number;
|
|
@@ -15,4 +9,3 @@ export declare function when(predicate: () => boolean, opts?: IWhenOptions): Pro
|
|
|
15
9
|
cancel(): void;
|
|
16
10
|
};
|
|
17
11
|
export declare function when(predicate: () => boolean, effect: Lambda, opts?: IWhenOptions): IReactionDisposer;
|
|
18
|
-
export {};
|
package/dist/core/reaction.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDerivation, IDerivationState_, IObservable, Lambda, TraceMode } from "../internal";
|
|
1
|
+
import { IDerivation, IDerivationState_, IObservable, Lambda, TraceMode, GenericAbortSignal } from "../internal";
|
|
2
2
|
/**
|
|
3
3
|
* Reactions are a special kind of derivations. Several things distinguishes them from normal reactive computations
|
|
4
4
|
*
|
|
@@ -52,7 +52,7 @@ export declare class Reaction implements IDerivation, IReactionPublic {
|
|
|
52
52
|
track(fn: () => void): void;
|
|
53
53
|
reportExceptionInDerivation_(error: any): void;
|
|
54
54
|
dispose(): void;
|
|
55
|
-
getDisposer_(): IReactionDisposer;
|
|
55
|
+
getDisposer_(abortSignal?: GenericAbortSignal): IReactionDisposer;
|
|
56
56
|
toString(): string;
|
|
57
57
|
trace(enterBreakPoint?: boolean): void;
|
|
58
58
|
}
|
package/dist/internal.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from "./types/flowannotation";
|
|
|
11
11
|
export * from "./types/computedannotation";
|
|
12
12
|
export * from "./types/observableannotation";
|
|
13
13
|
export * from "./types/autoannotation";
|
|
14
|
+
export * from "./types/generic-abort-signal";
|
|
14
15
|
export * from "./api/observable";
|
|
15
16
|
export * from "./api/computed";
|
|
16
17
|
export * from "./core/action";
|
|
@@ -2246,10 +2246,15 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2246
2246
|
}
|
|
2247
2247
|
}
|
|
2248
2248
|
};
|
|
2249
|
-
_proto.getDisposer_ = function getDisposer_() {
|
|
2250
|
-
var
|
|
2251
|
-
|
|
2252
|
-
|
|
2249
|
+
_proto.getDisposer_ = function getDisposer_(abortSignal) {
|
|
2250
|
+
var _this2 = this;
|
|
2251
|
+
var dispose = function dispose() {
|
|
2252
|
+
_this2.dispose();
|
|
2253
|
+
abortSignal == null ? void 0 : abortSignal.removeEventListener == null ? void 0 : abortSignal.removeEventListener("abort", dispose);
|
|
2254
|
+
};
|
|
2255
|
+
abortSignal == null ? void 0 : abortSignal.addEventListener == null ? void 0 : abortSignal.addEventListener("abort", dispose);
|
|
2256
|
+
dispose[$mobx] = this;
|
|
2257
|
+
return dispose;
|
|
2253
2258
|
};
|
|
2254
2259
|
_proto.toString = function toString() {
|
|
2255
2260
|
return "Reaction[" + this.name_ + "]";
|
|
@@ -2423,7 +2428,7 @@ function isAction(thing) {
|
|
|
2423
2428
|
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2424
2429
|
*/
|
|
2425
2430
|
function autorun(view, opts) {
|
|
2426
|
-
var _opts$name, _opts;
|
|
2431
|
+
var _opts$name, _opts, _opts2, _opts2$signal, _opts3;
|
|
2427
2432
|
if (opts === void 0) {
|
|
2428
2433
|
opts = EMPTY_OBJECT;
|
|
2429
2434
|
}
|
|
@@ -2462,8 +2467,10 @@ function autorun(view, opts) {
|
|
|
2462
2467
|
function reactionRunner() {
|
|
2463
2468
|
view(reaction);
|
|
2464
2469
|
}
|
|
2465
|
-
|
|
2466
|
-
|
|
2470
|
+
if (!((_opts2 = opts) != null && (_opts2$signal = _opts2.signal) != null && _opts2$signal.aborted)) {
|
|
2471
|
+
reaction.schedule_();
|
|
2472
|
+
}
|
|
2473
|
+
return reaction.getDisposer_((_opts3 = opts) == null ? void 0 : _opts3.signal);
|
|
2467
2474
|
}
|
|
2468
2475
|
var run = function run(f) {
|
|
2469
2476
|
return f();
|
|
@@ -2474,7 +2481,7 @@ function createSchedulerFromOptions(opts) {
|
|
|
2474
2481
|
} : run;
|
|
2475
2482
|
}
|
|
2476
2483
|
function reaction(expression, effect, opts) {
|
|
2477
|
-
var _opts$name2;
|
|
2484
|
+
var _opts$name2, _opts4, _opts4$signal, _opts5;
|
|
2478
2485
|
if (opts === void 0) {
|
|
2479
2486
|
opts = EMPTY_OBJECT;
|
|
2480
2487
|
}
|
|
@@ -2524,8 +2531,10 @@ function reaction(expression, effect, opts) {
|
|
|
2524
2531
|
}
|
|
2525
2532
|
firstTime = false;
|
|
2526
2533
|
}
|
|
2527
|
-
|
|
2528
|
-
|
|
2534
|
+
if (!((_opts4 = opts) != null && (_opts4$signal = _opts4.signal) != null && _opts4$signal.aborted)) {
|
|
2535
|
+
r.schedule_();
|
|
2536
|
+
}
|
|
2537
|
+
return r.getDisposer_((_opts5 = opts) == null ? void 0 : _opts5.signal);
|
|
2529
2538
|
}
|
|
2530
2539
|
function wrapErrorHandler(errorHandler, baseFn) {
|
|
2531
2540
|
return function () {
|