mobx 4.12.0 → 4.14.1
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/lib/api/autorun.d.ts +5 -0
- package/lib/api/configure.d.ts +10 -0
- package/lib/api/when.d.ts +5 -0
- package/lib/core/action.d.ts +13 -0
- package/lib/core/derivation.d.ts +7 -0
- package/lib/core/globalstate.d.ts +15 -0
- package/lib/core/reaction.d.ts +2 -1
- package/lib/mobx.d.ts +1 -1
- package/lib/mobx.es6.js +499 -394
- package/lib/mobx.js +498 -391
- package/lib/mobx.js.flow +20 -2
- package/lib/mobx.min.js +1 -1
- package/lib/mobx.module.js +498 -393
- package/lib/mobx.umd.js +498 -391
- package/lib/mobx.umd.min.js +1 -1
- package/lib/utils/comparer.d.ts +2 -0
- package/lib/utils/eq.d.ts +1 -1
- package/lib/utils/utils.d.ts +1 -0
- package/package.json +1 -1
package/lib/api/autorun.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { IReactionPublic, IReactionDisposer, IEqualsComparer } from "../internal
|
|
|
2
2
|
export interface IAutorunOptions {
|
|
3
3
|
delay?: number;
|
|
4
4
|
name?: string;
|
|
5
|
+
/**
|
|
6
|
+
* Experimental.
|
|
7
|
+
* Warns if the view doesn't track observables
|
|
8
|
+
*/
|
|
9
|
+
requiresObservable?: boolean;
|
|
5
10
|
scheduler?: (callback: () => void) => any;
|
|
6
11
|
onError?: (error: any) => void;
|
|
7
12
|
}
|
package/lib/api/configure.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export declare function configure(options: {
|
|
2
2
|
enforceActions?: boolean | "strict" | "never" | "always" | "observed";
|
|
3
3
|
computedRequiresReaction?: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* (Experimental)
|
|
6
|
+
* Warn if you try to create to derivation / reactive context without accessing any observable.
|
|
7
|
+
*/
|
|
8
|
+
reactionRequiresObservable?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* (Experimental)
|
|
11
|
+
* Warn if observables are accessed outside a reactive context
|
|
12
|
+
*/
|
|
13
|
+
observableRequiresReaction?: boolean;
|
|
4
14
|
computedConfigurable?: boolean;
|
|
5
15
|
isolateGlobalState?: boolean;
|
|
6
16
|
disableErrorBoundaries?: boolean;
|
package/lib/api/when.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { Lambda, IReactionDisposer } from "../internal";
|
|
|
2
2
|
export interface IWhenOptions {
|
|
3
3
|
name?: string;
|
|
4
4
|
timeout?: number;
|
|
5
|
+
/**
|
|
6
|
+
* Experimental.
|
|
7
|
+
* Warns if the view doesn't track observables
|
|
8
|
+
*/
|
|
9
|
+
requiresObservable?: boolean;
|
|
5
10
|
onError?: (error: any) => void;
|
|
6
11
|
}
|
|
7
12
|
export declare function when(predicate: () => boolean, opts?: IWhenOptions): Promise<void> & {
|
package/lib/core/action.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
import { IDerivation } from "../internal";
|
|
1
2
|
export interface IAction {
|
|
2
3
|
isMobxAction: boolean;
|
|
3
4
|
}
|
|
4
5
|
export declare function createAction(actionName: string, fn: Function): Function & IAction;
|
|
5
6
|
export declare function executeAction(actionName: string, fn: Function, scope?: any, args?: IArguments): any;
|
|
7
|
+
export interface IActionRunInfo {
|
|
8
|
+
prevDerivation: IDerivation | null;
|
|
9
|
+
prevAllowStateChanges: boolean;
|
|
10
|
+
prevAllowStateReads: boolean;
|
|
11
|
+
notifySpy: boolean;
|
|
12
|
+
startTime: number;
|
|
13
|
+
error?: any;
|
|
14
|
+
parentActionId: number;
|
|
15
|
+
actionId: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function _startAction(actionName: string, scope: any, args?: IArguments): IActionRunInfo;
|
|
18
|
+
export declare function _endAction(runInfo: IActionRunInfo): void;
|
|
6
19
|
export declare function allowStateChanges<T>(allowStateChanges: boolean, func: () => T): T;
|
|
7
20
|
export declare function allowStateChangesStart(allowStateChanges: boolean): boolean;
|
|
8
21
|
export declare function allowStateChangesEnd(prev: boolean): void;
|
package/lib/core/derivation.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ export interface IDerivation extends IDepTreeNode {
|
|
|
30
30
|
__mapid: string;
|
|
31
31
|
onBecomeStale(): void;
|
|
32
32
|
isTracing: TraceMode;
|
|
33
|
+
/**
|
|
34
|
+
* warn if the derivation has no dependencies after creation/update
|
|
35
|
+
*/
|
|
36
|
+
requiresObservable?: boolean;
|
|
33
37
|
}
|
|
34
38
|
export declare class CaughtException {
|
|
35
39
|
cause: any;
|
|
@@ -50,6 +54,7 @@ export declare function isCaughtException(e: any): e is CaughtException;
|
|
|
50
54
|
export declare function shouldCompute(derivation: IDerivation): boolean;
|
|
51
55
|
export declare function isComputingDerivation(): boolean;
|
|
52
56
|
export declare function checkIfStateModificationsAreAllowed(atom: IAtom): void;
|
|
57
|
+
export declare function checkIfStateReadsAreAllowed(observable: IObservable): void;
|
|
53
58
|
/**
|
|
54
59
|
* Executes the provided function `f` and tracks which observables are being accessed.
|
|
55
60
|
* The tracking information is stored on the `derivation` object and the derivation is registered
|
|
@@ -60,6 +65,8 @@ export declare function clearObserving(derivation: IDerivation): void;
|
|
|
60
65
|
export declare function untracked<T>(action: () => T): T;
|
|
61
66
|
export declare function untrackedStart(): IDerivation | null;
|
|
62
67
|
export declare function untrackedEnd(prev: IDerivation | null): void;
|
|
68
|
+
export declare function allowStateReadsStart(allowStateReads: boolean): boolean;
|
|
69
|
+
export declare function allowStateReadsEnd(prev: boolean): void;
|
|
63
70
|
/**
|
|
64
71
|
* needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
|
|
65
72
|
*
|
|
@@ -55,6 +55,11 @@ export declare class MobXGlobals {
|
|
|
55
55
|
* To ensure that those functions stay pure.
|
|
56
56
|
*/
|
|
57
57
|
allowStateChanges: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Is it allowed to read observables at this point?
|
|
60
|
+
* Used to hold the state needed for `observableRequiresReaction`
|
|
61
|
+
*/
|
|
62
|
+
allowStateReads: boolean;
|
|
58
63
|
/**
|
|
59
64
|
* If strict mode is enabled, state changes are by default not allowed
|
|
60
65
|
*/
|
|
@@ -73,6 +78,16 @@ export declare class MobXGlobals {
|
|
|
73
78
|
* Warn if computed values are accessed outside a reactive context
|
|
74
79
|
*/
|
|
75
80
|
computedRequiresReaction: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* (Experimental)
|
|
83
|
+
* Warn if you try to create to derivation / reactive context without accessing any observable.
|
|
84
|
+
*/
|
|
85
|
+
reactionRequiresObservable: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* (Experimental)
|
|
88
|
+
* Warn if observables are accessed outside a reactive context
|
|
89
|
+
*/
|
|
90
|
+
observableRequiresReaction: boolean;
|
|
76
91
|
/**
|
|
77
92
|
* Allows overwriting of computed properties, useful in tests but not prod as it can cause
|
|
78
93
|
* memory leaks. See https://github.com/mobxjs/mobx/issues/1867
|
package/lib/core/reaction.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare class Reaction implements IDerivation, IReactionPublic {
|
|
|
29
29
|
name: string;
|
|
30
30
|
private onInvalidate;
|
|
31
31
|
private errorHandler?;
|
|
32
|
+
requiresObservable: boolean;
|
|
32
33
|
observing: IObservable[];
|
|
33
34
|
newObserving: IObservable[];
|
|
34
35
|
dependenciesState: IDerivationState;
|
|
@@ -41,7 +42,7 @@ export declare class Reaction implements IDerivation, IReactionPublic {
|
|
|
41
42
|
_isTrackPending: boolean;
|
|
42
43
|
_isRunning: boolean;
|
|
43
44
|
isTracing: TraceMode;
|
|
44
|
-
constructor(name: string, onInvalidate: () => void, errorHandler?: ((error: any, derivation: IDerivation) => void) | undefined);
|
|
45
|
+
constructor(name: string, onInvalidate: () => void, errorHandler?: ((error: any, derivation: IDerivation) => void) | undefined, requiresObservable?: boolean);
|
|
45
46
|
onBecomeStale(): void;
|
|
46
47
|
schedule(): void;
|
|
47
48
|
isScheduled(): boolean;
|
package/lib/mobx.d.ts
CHANGED
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
* - utils/ Utility stuff.
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
|
-
export { IObservable, IDepTreeNode, Reaction, IReactionPublic, IReactionDisposer, IDerivation, untracked, IDerivationState, IAtom, createAtom, IAction, spy, IComputedValue, IEqualsComparer, comparer, IEnhancer, IInterceptable, IInterceptor, IListenable, IObjectWillChange, IObjectDidChange, IObservableObject, isObservableObject, IValueDidChange, IValueWillChange, IObservableValue, isObservableValue as isBoxedObservable, IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice, isObservableArray, IKeyValueMap, ObservableMap, IMapEntries, IMapEntry, IMapWillChange, IMapDidChange, isObservableMap, IObservableMapInitialValues, ObservableSet, isObservableSet, ISetDidChange, ISetWillChange, IObservableSetInitialValues, transaction, observable, IObservableFactory, IObservableFactories, computed, IComputed, isObservable, isObservableProp, isComputed, isComputedProp, extendObservable, extendShallowObservable, observe, intercept, autorun, IAutorunOptions, reaction, IReactionOptions, when, IWhenOptions, action, isAction, runInAction, IActionFactory, keys, values, entries, set, remove, has, get, decorate, configure, onBecomeObserved, onBecomeUnobserved, flow, toJS, trace, IObserverTree, IDependencyTree, getDependencyTree, getObserverTree, resetGlobalState as _resetGlobalState, getGlobalState as _getGlobalState, getDebugName, getAtom, getAdministration as _getAdministration, allowStateChanges as _allowStateChanges, allowStateChangesInsideComputed as _allowStateChangesInsideComputed, Lambda, isArrayLike, isComputingDerivation as _isComputingDerivation, onReactionError, interceptReads as _interceptReads, IComputedValueOptions } from "./internal";
|
|
18
|
+
export { IObservable, IDepTreeNode, Reaction, IReactionPublic, IReactionDisposer, IDerivation, untracked, IDerivationState, IAtom, createAtom, IAction, spy, IComputedValue, IEqualsComparer, comparer, IEnhancer, IInterceptable, IInterceptor, IListenable, IObjectWillChange, IObjectDidChange, IObservableObject, isObservableObject, IValueDidChange, IValueWillChange, IObservableValue, isObservableValue as isBoxedObservable, IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice, isObservableArray, IKeyValueMap, ObservableMap, IMapEntries, IMapEntry, IMapWillChange, IMapDidChange, isObservableMap, IObservableMapInitialValues, ObservableSet, isObservableSet, ISetDidChange, ISetWillChange, IObservableSetInitialValues, transaction, observable, IObservableFactory, IObservableFactories, computed, IComputed, isObservable, isObservableProp, isComputed, isComputedProp, extendObservable, extendShallowObservable, observe, intercept, autorun, IAutorunOptions, reaction, IReactionOptions, when, IWhenOptions, action, isAction, runInAction, IActionFactory, keys, values, entries, set, remove, has, get, decorate, configure, onBecomeObserved, onBecomeUnobserved, flow, toJS, trace, IObserverTree, IDependencyTree, getDependencyTree, getObserverTree, resetGlobalState as _resetGlobalState, getGlobalState as _getGlobalState, getDebugName, getAtom, getAdministration as _getAdministration, allowStateChanges as _allowStateChanges, allowStateChangesInsideComputed as _allowStateChangesInsideComputed, Lambda, isArrayLike, isComputingDerivation as _isComputingDerivation, onReactionError, interceptReads as _interceptReads, IComputedValueOptions, IActionRunInfo, _startAction, _endAction } from "./internal";
|
|
19
19
|
export declare const $mobx = "$mobx";
|