mobx 4.15.0 → 4.15.4

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +827 -552
  2. package/README.md +155 -98
  3. package/lib/api/action.d.ts +13 -25
  4. package/lib/api/actiondecorator.d.ts +27 -16
  5. package/lib/api/autorun.d.ts +24 -24
  6. package/lib/api/become-observed.d.ts +5 -5
  7. package/lib/api/computed.d.ts +14 -14
  8. package/lib/api/configure.d.ts +19 -19
  9. package/lib/api/decorate.d.ts +6 -6
  10. package/lib/api/extendobservable.d.ts +7 -7
  11. package/lib/api/extras.d.ts +10 -10
  12. package/lib/api/flow.d.ts +9 -9
  13. package/lib/api/intercept-read.d.ts +8 -8
  14. package/lib/api/intercept.d.ts +8 -8
  15. package/lib/api/iscomputed.d.ts +3 -3
  16. package/lib/api/isobservable.d.ts +2 -2
  17. package/lib/api/object-api.d.ts +34 -34
  18. package/lib/api/observable.d.ts +54 -54
  19. package/lib/api/observabledecorator.d.ts +6 -6
  20. package/lib/api/observe.d.ts +8 -8
  21. package/lib/api/tojs.d.ts +11 -11
  22. package/lib/api/trace.d.ts +3 -3
  23. package/lib/api/transaction.d.ts +8 -8
  24. package/lib/api/when.d.ts +15 -15
  25. package/lib/core/action.d.ts +22 -22
  26. package/lib/core/atom.d.ts +40 -40
  27. package/lib/core/computedvalue.d.ts +93 -93
  28. package/lib/core/derivation.d.ts +74 -74
  29. package/lib/core/globalstate.d.ts +106 -106
  30. package/lib/core/observable.d.ts +44 -44
  31. package/lib/core/reaction.d.ts +63 -63
  32. package/lib/core/spy.d.ts +6 -6
  33. package/lib/index.js +7 -0
  34. package/lib/internal.d.ts +44 -44
  35. package/lib/mobx.d.ts +19 -19
  36. package/lib/mobx.es6.js +4340 -4330
  37. package/lib/mobx.js +4384 -4419
  38. package/lib/mobx.js.flow +1 -0
  39. package/lib/mobx.min.js +1 -1
  40. package/lib/mobx.module.js +4431 -4421
  41. package/lib/mobx.umd.js +4431 -4419
  42. package/lib/mobx.umd.min.js +1 -1
  43. package/lib/types/intercept-utils.d.ts +9 -9
  44. package/lib/types/listen-utils.d.ts +8 -8
  45. package/lib/types/modifiers.d.ts +7 -7
  46. package/lib/types/observablearray.d.ts +78 -78
  47. package/lib/types/observablemap.d.ts +83 -83
  48. package/lib/types/observableobject.d.ts +65 -65
  49. package/lib/types/observableset.d.ts +49 -49
  50. package/lib/types/observablevalue.d.ts +37 -37
  51. package/lib/types/type-utils.d.ts +4 -4
  52. package/lib/utils/comparer.d.ts +14 -14
  53. package/lib/utils/decorators2.d.ts +7 -7
  54. package/lib/utils/eq.d.ts +1 -1
  55. package/lib/utils/iterable.d.ts +5 -5
  56. package/lib/utils/utils.d.ts +43 -43
  57. package/package.json +7 -89
@@ -1,93 +1,93 @@
1
- import { IObservable, IValueDidChange, Lambda, IEqualsComparer, IDerivation, IDerivationState, CaughtException, TraceMode } from "../internal";
2
- export interface IComputedValue<T> {
3
- get(): T;
4
- set(value: T): void;
5
- observe(listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean): Lambda;
6
- }
7
- export interface IComputedValueOptions<T> {
8
- get?: () => T;
9
- set?: (value: T) => void;
10
- name?: string;
11
- equals?: IEqualsComparer<T>;
12
- context?: any;
13
- requiresReaction?: boolean;
14
- keepAlive?: boolean;
15
- }
16
- /**
17
- * A node in the state dependency root that observes other nodes, and can be observed itself.
18
- *
19
- * ComputedValue will remember the result of the computation for the duration of the batch, or
20
- * while being observed.
21
- *
22
- * During this time it will recompute only when one of its direct dependencies changed,
23
- * but only when it is being accessed with `ComputedValue.get()`.
24
- *
25
- * Implementation description:
26
- * 1. First time it's being accessed it will compute and remember result
27
- * give back remembered result until 2. happens
28
- * 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
29
- * 3. When it's being accessed, recompute if any shallow dependency changed.
30
- * if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
31
- * go to step 2. either way
32
- *
33
- * If at any point it's outside batch and it isn't observed: reset everything and go to 1.
34
- */
35
- export declare class ComputedValue<T> implements IObservable, IComputedValue<T>, IDerivation {
36
- dependenciesState: IDerivationState;
37
- observing: IObservable[];
38
- newObserving: null;
39
- isBeingObserved: boolean;
40
- isPendingUnobservation: boolean;
41
- observers: never[];
42
- observersIndexes: {};
43
- diffValue: number;
44
- runId: number;
45
- lastAccessedBy: number;
46
- lowestObserverState: IDerivationState;
47
- unboundDepsCount: number;
48
- __mapid: string;
49
- protected value: T | undefined | CaughtException;
50
- name: string;
51
- triggeredBy: string;
52
- isComputing: boolean;
53
- isRunningSetter: boolean;
54
- derivation: () => T;
55
- setter: (value: T) => void;
56
- isTracing: TraceMode;
57
- scope: Object | undefined;
58
- private equals;
59
- private requiresReaction;
60
- private keepAlive;
61
- /**
62
- * Create a new computed value based on a function expression.
63
- *
64
- * The `name` property is for debug purposes only.
65
- *
66
- * The `equals` property specifies the comparer function to use to determine if a newly produced
67
- * value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
68
- * compares based on identity comparison (===), and `structualComparer` deeply compares the structure.
69
- * Structural comparison can be convenient if you always produce a new aggregated object and
70
- * don't want to notify observers if it is structurally the same.
71
- * This is useful for working with vectors, mouse coordinates etc.
72
- */
73
- constructor(options: IComputedValueOptions<T>);
74
- onBecomeStale(): void;
75
- onBecomeUnobserved(): void;
76
- onBecomeObserved(): void;
77
- /**
78
- * Returns the current value of this computed value.
79
- * Will evaluate its computation first if needed.
80
- */
81
- get(): T;
82
- peek(): T;
83
- set(value: T): void;
84
- private trackAndCompute;
85
- computeValue(track: boolean): T | CaughtException;
86
- suspend(): void;
87
- observe(listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean): Lambda;
88
- warnAboutUntrackedRead(): void;
89
- toJSON(): T;
90
- toString(): string;
91
- valueOf(): T;
92
- }
93
- export declare const isComputedValue: (x: any) => x is ComputedValue<unknown>;
1
+ import { IObservable, IValueDidChange, Lambda, IEqualsComparer, IDerivation, IDerivationState, CaughtException, TraceMode } from "../internal";
2
+ export interface IComputedValue<T> {
3
+ get(): T;
4
+ set(value: T): void;
5
+ observe(listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean): Lambda;
6
+ }
7
+ export interface IComputedValueOptions<T> {
8
+ get?: () => T;
9
+ set?: (value: T) => void;
10
+ name?: string;
11
+ equals?: IEqualsComparer<T>;
12
+ context?: any;
13
+ requiresReaction?: boolean;
14
+ keepAlive?: boolean;
15
+ }
16
+ /**
17
+ * A node in the state dependency root that observes other nodes, and can be observed itself.
18
+ *
19
+ * ComputedValue will remember the result of the computation for the duration of the batch, or
20
+ * while being observed.
21
+ *
22
+ * During this time it will recompute only when one of its direct dependencies changed,
23
+ * but only when it is being accessed with `ComputedValue.get()`.
24
+ *
25
+ * Implementation description:
26
+ * 1. First time it's being accessed it will compute and remember result
27
+ * give back remembered result until 2. happens
28
+ * 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
29
+ * 3. When it's being accessed, recompute if any shallow dependency changed.
30
+ * if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
31
+ * go to step 2. either way
32
+ *
33
+ * If at any point it's outside batch and it isn't observed: reset everything and go to 1.
34
+ */
35
+ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>, IDerivation {
36
+ dependenciesState: IDerivationState;
37
+ observing: IObservable[];
38
+ newObserving: null;
39
+ isBeingObserved: boolean;
40
+ isPendingUnobservation: boolean;
41
+ observers: never[];
42
+ observersIndexes: {};
43
+ diffValue: number;
44
+ runId: number;
45
+ lastAccessedBy: number;
46
+ lowestObserverState: IDerivationState;
47
+ unboundDepsCount: number;
48
+ __mapid: string;
49
+ protected value: T | undefined | CaughtException;
50
+ name: string;
51
+ triggeredBy?: string;
52
+ isComputing: boolean;
53
+ isRunningSetter: boolean;
54
+ derivation: () => T;
55
+ setter?: (value: T) => void;
56
+ isTracing: TraceMode;
57
+ scope: Object | undefined;
58
+ private equals;
59
+ private requiresReaction;
60
+ private keepAlive;
61
+ /**
62
+ * Create a new computed value based on a function expression.
63
+ *
64
+ * The `name` property is for debug purposes only.
65
+ *
66
+ * The `equals` property specifies the comparer function to use to determine if a newly produced
67
+ * value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
68
+ * compares based on identity comparison (===), and `structualComparer` deeply compares the structure.
69
+ * Structural comparison can be convenient if you always produce a new aggregated object and
70
+ * don't want to notify observers if it is structurally the same.
71
+ * This is useful for working with vectors, mouse coordinates etc.
72
+ */
73
+ constructor(options: IComputedValueOptions<T>);
74
+ onBecomeStale(): void;
75
+ onBecomeUnobserved(): void;
76
+ onBecomeObserved(): void;
77
+ /**
78
+ * Returns the current value of this computed value.
79
+ * Will evaluate its computation first if needed.
80
+ */
81
+ get(): T;
82
+ peek(): T;
83
+ set(value: T): void;
84
+ private trackAndCompute;
85
+ computeValue(track: boolean): T | CaughtException;
86
+ suspend(): void;
87
+ observe(listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean): Lambda;
88
+ warnAboutUntrackedRead(): void;
89
+ toJSON(): T;
90
+ toString(): string;
91
+ valueOf(): T;
92
+ }
93
+ export declare const isComputedValue: (x: any) => x is ComputedValue<unknown>;
@@ -1,74 +1,74 @@
1
- import { IDepTreeNode, IObservable, IAtom } from "../internal";
2
- export declare enum IDerivationState {
3
- NOT_TRACKING = -1,
4
- UP_TO_DATE = 0,
5
- POSSIBLY_STALE = 1,
6
- STALE = 2
7
- }
8
- export declare enum TraceMode {
9
- NONE = 0,
10
- LOG = 1,
11
- BREAK = 2
12
- }
13
- /**
14
- * A derivation is everything that can be derived from the state (all the atoms) in a pure manner.
15
- * See https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
16
- */
17
- export interface IDerivation extends IDepTreeNode {
18
- observing: IObservable[];
19
- newObserving: null | IObservable[];
20
- dependenciesState: IDerivationState;
21
- /**
22
- * Id of the current run of a derivation. Each time the derivation is tracked
23
- * this number is increased by one. This number is globally unique
24
- */
25
- runId: number;
26
- /**
27
- * amount of dependencies used by the derivation in this run, which has not been bound yet.
28
- */
29
- unboundDepsCount: number;
30
- __mapid: string;
31
- onBecomeStale(): void;
32
- isTracing: TraceMode;
33
- /**
34
- * warn if the derivation has no dependencies after creation/update
35
- */
36
- requiresObservable?: boolean;
37
- }
38
- export declare class CaughtException {
39
- cause: any;
40
- constructor(cause: any);
41
- }
42
- export declare function isCaughtException(e: any): e is CaughtException;
43
- /**
44
- * Finds out whether any dependency of the derivation has actually changed.
45
- * If dependenciesState is 1 then it will recalculate dependencies,
46
- * if any dependency changed it will propagate it by changing dependenciesState to 2.
47
- *
48
- * By iterating over the dependencies in the same order that they were reported and
49
- * stopping on the first change, all the recalculations are only called for ComputedValues
50
- * that will be tracked by derivation. That is because we assume that if the first x
51
- * dependencies of the derivation doesn't change then the derivation should run the same way
52
- * up until accessing x-th dependency.
53
- */
54
- export declare function shouldCompute(derivation: IDerivation): boolean;
55
- export declare function isComputingDerivation(): boolean;
56
- export declare function checkIfStateModificationsAreAllowed(atom: IAtom): void;
57
- export declare function checkIfStateReadsAreAllowed(observable: IObservable): void;
58
- /**
59
- * Executes the provided function `f` and tracks which observables are being accessed.
60
- * The tracking information is stored on the `derivation` object and the derivation is registered
61
- * as observer of any of the accessed observables.
62
- */
63
- export declare function trackDerivedFunction<T>(derivation: IDerivation, f: () => T, context: any): any;
64
- export declare function clearObserving(derivation: IDerivation): void;
65
- export declare function untracked<T>(action: () => T): T;
66
- export declare function untrackedStart(): IDerivation | null;
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;
70
- /**
71
- * needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
72
- *
73
- */
74
- export declare function changeDependenciesStateTo0(derivation: IDerivation): void;
1
+ import { IDepTreeNode, IObservable, IAtom } from "../internal";
2
+ export declare enum IDerivationState {
3
+ NOT_TRACKING = -1,
4
+ UP_TO_DATE = 0,
5
+ POSSIBLY_STALE = 1,
6
+ STALE = 2
7
+ }
8
+ export declare enum TraceMode {
9
+ NONE = 0,
10
+ LOG = 1,
11
+ BREAK = 2
12
+ }
13
+ /**
14
+ * A derivation is everything that can be derived from the state (all the atoms) in a pure manner.
15
+ * See https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
16
+ */
17
+ export interface IDerivation extends IDepTreeNode {
18
+ observing: IObservable[];
19
+ newObserving: null | IObservable[];
20
+ dependenciesState: IDerivationState;
21
+ /**
22
+ * Id of the current run of a derivation. Each time the derivation is tracked
23
+ * this number is increased by one. This number is globally unique
24
+ */
25
+ runId: number;
26
+ /**
27
+ * amount of dependencies used by the derivation in this run, which has not been bound yet.
28
+ */
29
+ unboundDepsCount: number;
30
+ __mapid: string;
31
+ onBecomeStale(): void;
32
+ isTracing: TraceMode;
33
+ /**
34
+ * warn if the derivation has no dependencies after creation/update
35
+ */
36
+ requiresObservable?: boolean;
37
+ }
38
+ export declare class CaughtException {
39
+ cause: any;
40
+ constructor(cause: any);
41
+ }
42
+ export declare function isCaughtException(e: any): e is CaughtException;
43
+ /**
44
+ * Finds out whether any dependency of the derivation has actually changed.
45
+ * If dependenciesState is 1 then it will recalculate dependencies,
46
+ * if any dependency changed it will propagate it by changing dependenciesState to 2.
47
+ *
48
+ * By iterating over the dependencies in the same order that they were reported and
49
+ * stopping on the first change, all the recalculations are only called for ComputedValues
50
+ * that will be tracked by derivation. That is because we assume that if the first x
51
+ * dependencies of the derivation doesn't change then the derivation should run the same way
52
+ * up until accessing x-th dependency.
53
+ */
54
+ export declare function shouldCompute(derivation: IDerivation): boolean;
55
+ export declare function isComputingDerivation(): boolean;
56
+ export declare function checkIfStateModificationsAreAllowed(atom: IAtom): void;
57
+ export declare function checkIfStateReadsAreAllowed(observable: IObservable): void;
58
+ /**
59
+ * Executes the provided function `f` and tracks which observables are being accessed.
60
+ * The tracking information is stored on the `derivation` object and the derivation is registered
61
+ * as observer of any of the accessed observables.
62
+ */
63
+ export declare function trackDerivedFunction<T>(derivation: IDerivation, f: () => T, context: any): any;
64
+ export declare function clearObserving(derivation: IDerivation): void;
65
+ export declare function untracked<T>(action: () => T): T;
66
+ export declare function untrackedStart(): IDerivation | null;
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;
70
+ /**
71
+ * needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
72
+ *
73
+ */
74
+ export declare function changeDependenciesStateTo0(derivation: IDerivation): void;
@@ -1,106 +1,106 @@
1
- import { IDerivation, IObservable, Reaction } from "../internal";
2
- export declare type IUNCHANGED = {};
3
- export declare class MobXGlobals {
4
- /**
5
- * MobXGlobals version.
6
- * MobX compatiblity with other versions loaded in memory as long as this version matches.
7
- * It indicates that the global state still stores similar information
8
- *
9
- * N.B: this version is unrelated to the package version of MobX, and is only the version of the
10
- * internal state storage of MobX, and can be the same across many different package versions
11
- */
12
- version: number;
13
- /**
14
- * globally unique token to signal unchanged
15
- */
16
- UNCHANGED: IUNCHANGED;
17
- /**
18
- * Currently running derivation
19
- */
20
- trackingDerivation: IDerivation | null;
21
- /**
22
- * Are we running a computation currently? (not a reaction)
23
- */
24
- computationDepth: number;
25
- /**
26
- * Each time a derivation is tracked, it is assigned a unique run-id
27
- */
28
- runId: number;
29
- /**
30
- * 'guid' for general purpose. Will be persisted amongst resets.
31
- */
32
- mobxGuid: number;
33
- /**
34
- * Are we in a batch block? (and how many of them)
35
- */
36
- inBatch: number;
37
- /**
38
- * Observables that don't have observers anymore, and are about to be
39
- * suspended, unless somebody else accesses it in the same batch
40
- *
41
- * @type {IObservable[]}
42
- */
43
- pendingUnobservations: IObservable[];
44
- /**
45
- * List of scheduled, not yet executed, reactions.
46
- */
47
- pendingReactions: Reaction[];
48
- /**
49
- * Are we currently processing reactions?
50
- */
51
- isRunningReactions: boolean;
52
- /**
53
- * Is it allowed to change observables at this point?
54
- * In general, MobX doesn't allow that when running computations and React.render.
55
- * To ensure that those functions stay pure.
56
- */
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;
63
- /**
64
- * If strict mode is enabled, state changes are by default not allowed
65
- */
66
- enforceActions: boolean | "strict";
67
- /**
68
- * Spy callbacks
69
- */
70
- spyListeners: {
71
- (change: any): void;
72
- }[];
73
- /**
74
- * Globally attached error handlers that react specifically to errors in reactions
75
- */
76
- globalReactionErrorHandlers: ((error: any, derivation: IDerivation) => void)[];
77
- /**
78
- * Warn if computed values are accessed outside a reactive context
79
- */
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;
91
- /**
92
- * Allows overwriting of computed properties, useful in tests but not prod as it can cause
93
- * memory leaks. See https://github.com/mobxjs/mobx/issues/1867
94
- */
95
- computedConfigurable: boolean;
96
- disableErrorBoundaries: boolean;
97
- suppressReactionErrors: boolean;
98
- }
99
- export declare let globalState: MobXGlobals;
100
- export declare function isolateGlobalState(): void;
101
- export declare function getGlobalState(): any;
102
- /**
103
- * For testing purposes only; this will break the internal state of existing observables,
104
- * but can be used to get back at a stable state after throwing errors
105
- */
106
- export declare function resetGlobalState(): void;
1
+ import { IDerivation, IObservable, Reaction } from "../internal";
2
+ export declare type IUNCHANGED = {};
3
+ export declare class MobXGlobals {
4
+ /**
5
+ * MobXGlobals version.
6
+ * MobX compatiblity with other versions loaded in memory as long as this version matches.
7
+ * It indicates that the global state still stores similar information
8
+ *
9
+ * N.B: this version is unrelated to the package version of MobX, and is only the version of the
10
+ * internal state storage of MobX, and can be the same across many different package versions
11
+ */
12
+ version: number;
13
+ /**
14
+ * globally unique token to signal unchanged
15
+ */
16
+ UNCHANGED: IUNCHANGED;
17
+ /**
18
+ * Currently running derivation
19
+ */
20
+ trackingDerivation: IDerivation | null;
21
+ /**
22
+ * Are we running a computation currently? (not a reaction)
23
+ */
24
+ computationDepth: number;
25
+ /**
26
+ * Each time a derivation is tracked, it is assigned a unique run-id
27
+ */
28
+ runId: number;
29
+ /**
30
+ * 'guid' for general purpose. Will be persisted amongst resets.
31
+ */
32
+ mobxGuid: number;
33
+ /**
34
+ * Are we in a batch block? (and how many of them)
35
+ */
36
+ inBatch: number;
37
+ /**
38
+ * Observables that don't have observers anymore, and are about to be
39
+ * suspended, unless somebody else accesses it in the same batch
40
+ *
41
+ * @type {IObservable[]}
42
+ */
43
+ pendingUnobservations: IObservable[];
44
+ /**
45
+ * List of scheduled, not yet executed, reactions.
46
+ */
47
+ pendingReactions: Reaction[];
48
+ /**
49
+ * Are we currently processing reactions?
50
+ */
51
+ isRunningReactions: boolean;
52
+ /**
53
+ * Is it allowed to change observables at this point?
54
+ * In general, MobX doesn't allow that when running computations and React.render.
55
+ * To ensure that those functions stay pure.
56
+ */
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;
63
+ /**
64
+ * If strict mode is enabled, state changes are by default not allowed
65
+ */
66
+ enforceActions: boolean | "strict";
67
+ /**
68
+ * Spy callbacks
69
+ */
70
+ spyListeners: {
71
+ (change: any): void;
72
+ }[];
73
+ /**
74
+ * Globally attached error handlers that react specifically to errors in reactions
75
+ */
76
+ globalReactionErrorHandlers: ((error: any, derivation: IDerivation) => void)[];
77
+ /**
78
+ * Warn if computed values are accessed outside a reactive context
79
+ */
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;
91
+ /**
92
+ * Allows overwriting of computed properties, useful in tests but not prod as it can cause
93
+ * memory leaks. See https://github.com/mobxjs/mobx/issues/1867
94
+ */
95
+ computedConfigurable: boolean;
96
+ disableErrorBoundaries: boolean;
97
+ suppressReactionErrors: boolean;
98
+ }
99
+ export declare let globalState: MobXGlobals;
100
+ export declare function isolateGlobalState(): void;
101
+ export declare function getGlobalState(): any;
102
+ /**
103
+ * For testing purposes only; this will break the internal state of existing observables,
104
+ * but can be used to get back at a stable state after throwing errors
105
+ */
106
+ export declare function resetGlobalState(): void;
@@ -1,44 +1,44 @@
1
- import { IDerivation, IDerivationState } from "../internal";
2
- export interface IDepTreeNode {
3
- name: string;
4
- observing?: IObservable[];
5
- }
6
- export interface IObservable extends IDepTreeNode {
7
- diffValue: number;
8
- /**
9
- * Id of the derivation *run* that last accessed this observable.
10
- * If this id equals the *run* id of the current derivation,
11
- * the dependency is already established
12
- */
13
- lastAccessedBy: number;
14
- isBeingObserved: boolean;
15
- lowestObserverState: IDerivationState;
16
- isPendingUnobservation: boolean;
17
- observers: IDerivation[];
18
- observersIndexes: {};
19
- onBecomeUnobserved(): void;
20
- onBecomeObserved(): void;
21
- }
22
- export declare function hasObservers(observable: IObservable): boolean;
23
- export declare function getObservers(observable: IObservable): IDerivation[];
24
- export declare function addObserver(observable: IObservable, node: IDerivation): void;
25
- export declare function removeObserver(observable: IObservable, node: IDerivation): void;
26
- export declare function queueForUnobservation(observable: IObservable): void;
27
- /**
28
- * Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
29
- * During a batch `onBecomeUnobserved` will be called at most once per observable.
30
- * Avoids unnecessary recalculations.
31
- */
32
- export declare function startBatch(): void;
33
- export declare function endBatch(): void;
34
- export declare function reportObserved(observable: IObservable): boolean;
35
- /**
36
- * NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
37
- * It will propagate changes to observers from previous run
38
- * It's hard or maybe impossible (with reasonable perf) to get it right with current approach
39
- * Hopefully self reruning autoruns aren't a feature people should depend on
40
- * Also most basic use cases should be ok
41
- */
42
- export declare function propagateChanged(observable: IObservable): void;
43
- export declare function propagateChangeConfirmed(observable: IObservable): void;
44
- export declare function propagateMaybeChanged(observable: IObservable): void;
1
+ import { IDerivation, IDerivationState } from "../internal";
2
+ export interface IDepTreeNode {
3
+ name: string;
4
+ observing?: IObservable[];
5
+ }
6
+ export interface IObservable extends IDepTreeNode {
7
+ diffValue: number;
8
+ /**
9
+ * Id of the derivation *run* that last accessed this observable.
10
+ * If this id equals the *run* id of the current derivation,
11
+ * the dependency is already established
12
+ */
13
+ lastAccessedBy: number;
14
+ isBeingObserved: boolean;
15
+ lowestObserverState: IDerivationState;
16
+ isPendingUnobservation: boolean;
17
+ observers: IDerivation[];
18
+ observersIndexes: {};
19
+ onBecomeUnobserved(): void;
20
+ onBecomeObserved(): void;
21
+ }
22
+ export declare function hasObservers(observable: IObservable): boolean;
23
+ export declare function getObservers(observable: IObservable): IDerivation[];
24
+ export declare function addObserver(observable: IObservable, node: IDerivation): void;
25
+ export declare function removeObserver(observable: IObservable, node: IDerivation): void;
26
+ export declare function queueForUnobservation(observable: IObservable): void;
27
+ /**
28
+ * Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
29
+ * During a batch `onBecomeUnobserved` will be called at most once per observable.
30
+ * Avoids unnecessary recalculations.
31
+ */
32
+ export declare function startBatch(): void;
33
+ export declare function endBatch(): void;
34
+ export declare function reportObserved(observable: IObservable): boolean;
35
+ /**
36
+ * NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
37
+ * It will propagate changes to observers from previous run
38
+ * It's hard or maybe impossible (with reasonable perf) to get it right with current approach
39
+ * Hopefully self reruning autoruns aren't a feature people should depend on
40
+ * Also most basic use cases should be ok
41
+ */
42
+ export declare function propagateChanged(observable: IObservable): void;
43
+ export declare function propagateChangeConfirmed(observable: IObservable): void;
44
+ export declare function propagateMaybeChanged(observable: IObservable): void;