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,63 +1,63 @@
1
- import { IDerivation, IDerivationState, TraceMode, IObservable, Lambda } from "../internal";
2
- /**
3
- * Reactions are a special kind of derivations. Several things distinguishes them from normal reactive computations
4
- *
5
- * 1) They will always run, whether they are used by other computations or not.
6
- * This means that they are very suitable for triggering side effects like logging, updating the DOM and making network requests.
7
- * 2) They are not observable themselves
8
- * 3) They will always run after any 'normal' derivations
9
- * 4) They are allowed to change the state and thereby triggering themselves again, as long as they make sure the state propagates to a stable state in a reasonable amount of iterations.
10
- *
11
- * The state machine of a Reaction is as follows:
12
- *
13
- * 1) after creating, the reaction should be started by calling `runReaction` or by scheduling it (see also `autorun`)
14
- * 2) the `onInvalidate` handler should somehow result in a call to `this.track(someFunction)`
15
- * 3) all observables accessed in `someFunction` will be observed by this reaction.
16
- * 4) as soon as some of the dependencies has changed the Reaction will be rescheduled for another run (after the current mutation or transaction). `isScheduled` will yield true once a dependency is stale and during this period
17
- * 5) `onInvalidate` will be called, and we are back at step 1.
18
- *
19
- */
20
- export interface IReactionPublic {
21
- dispose(): void;
22
- trace(enterBreakPoint?: boolean): void;
23
- }
24
- export interface IReactionDisposer {
25
- (): void;
26
- $mobx: Reaction;
27
- }
28
- export declare class Reaction implements IDerivation, IReactionPublic {
29
- name: string;
30
- private onInvalidate;
31
- private errorHandler?;
32
- requiresObservable: boolean;
33
- observing: IObservable[];
34
- newObserving: IObservable[];
35
- dependenciesState: IDerivationState;
36
- diffValue: number;
37
- runId: number;
38
- unboundDepsCount: number;
39
- __mapid: string;
40
- isDisposed: boolean;
41
- _isScheduled: boolean;
42
- _isTrackPending: boolean;
43
- _isRunning: boolean;
44
- isTracing: TraceMode;
45
- constructor(name: string, onInvalidate: () => void, errorHandler?: ((error: any, derivation: IDerivation) => void) | undefined, requiresObservable?: boolean);
46
- onBecomeStale(): void;
47
- schedule(): void;
48
- isScheduled(): boolean;
49
- /**
50
- * internal, use schedule() if you intend to kick off a reaction
51
- */
52
- runReaction(): void;
53
- track(fn: () => void): void;
54
- reportExceptionInDerivation(error: any): void;
55
- dispose(): void;
56
- getDisposer(): IReactionDisposer;
57
- toString(): string;
58
- trace(enterBreakPoint?: boolean): void;
59
- }
60
- export declare function onReactionError(handler: (error: any, derivation: IDerivation) => void): Lambda;
61
- export declare function runReactions(): void;
62
- export declare const isReaction: (x: any) => x is Reaction;
63
- export declare function setReactionScheduler(fn: (f: () => void) => void): void;
1
+ import { IDerivation, IDerivationState, TraceMode, IObservable, Lambda } from "../internal";
2
+ /**
3
+ * Reactions are a special kind of derivations. Several things distinguishes them from normal reactive computations
4
+ *
5
+ * 1) They will always run, whether they are used by other computations or not.
6
+ * This means that they are very suitable for triggering side effects like logging, updating the DOM and making network requests.
7
+ * 2) They are not observable themselves
8
+ * 3) They will always run after any 'normal' derivations
9
+ * 4) They are allowed to change the state and thereby triggering themselves again, as long as they make sure the state propagates to a stable state in a reasonable amount of iterations.
10
+ *
11
+ * The state machine of a Reaction is as follows:
12
+ *
13
+ * 1) after creating, the reaction should be started by calling `runReaction` or by scheduling it (see also `autorun`)
14
+ * 2) the `onInvalidate` handler should somehow result in a call to `this.track(someFunction)`
15
+ * 3) all observables accessed in `someFunction` will be observed by this reaction.
16
+ * 4) as soon as some of the dependencies has changed the Reaction will be rescheduled for another run (after the current mutation or transaction). `isScheduled` will yield true once a dependency is stale and during this period
17
+ * 5) `onInvalidate` will be called, and we are back at step 1.
18
+ *
19
+ */
20
+ export interface IReactionPublic {
21
+ dispose(): void;
22
+ trace(enterBreakPoint?: boolean): void;
23
+ }
24
+ export interface IReactionDisposer {
25
+ (): void;
26
+ $mobx: Reaction;
27
+ }
28
+ export declare class Reaction implements IDerivation, IReactionPublic {
29
+ name: string;
30
+ private onInvalidate;
31
+ private errorHandler?;
32
+ requiresObservable: boolean;
33
+ observing: IObservable[];
34
+ newObserving: IObservable[];
35
+ dependenciesState: IDerivationState;
36
+ diffValue: number;
37
+ runId: number;
38
+ unboundDepsCount: number;
39
+ __mapid: string;
40
+ isDisposed: boolean;
41
+ _isScheduled: boolean;
42
+ _isTrackPending: boolean;
43
+ _isRunning: boolean;
44
+ isTracing: TraceMode;
45
+ constructor(name: string, onInvalidate: () => void, errorHandler?: ((error: any, derivation: IDerivation) => void) | undefined, requiresObservable?: boolean);
46
+ onBecomeStale(): void;
47
+ schedule(): void;
48
+ isScheduled(): boolean;
49
+ /**
50
+ * internal, use schedule() if you intend to kick off a reaction
51
+ */
52
+ runReaction(): void;
53
+ track(fn: () => void): void;
54
+ reportExceptionInDerivation(error: any): void;
55
+ dispose(): void;
56
+ getDisposer(): IReactionDisposer;
57
+ toString(): string;
58
+ trace(enterBreakPoint?: boolean): void;
59
+ }
60
+ export declare function onReactionError(handler: (error: any, derivation: IDerivation) => void): Lambda;
61
+ export declare function runReactions(): void;
62
+ export declare const isReaction: (x: any) => x is Reaction;
63
+ export declare function setReactionScheduler(fn: (f: () => void) => void): void;
package/lib/core/spy.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Lambda } from "../internal";
2
- export declare function isSpyEnabled(): boolean;
3
- export declare function spyReport(event: any): void;
4
- export declare function spyReportStart(event: any): void;
5
- export declare function spyReportEnd(change?: any): void;
6
- export declare function spy(listener: (change: any) => void): Lambda;
1
+ import { Lambda } from "../internal";
2
+ export declare function isSpyEnabled(): boolean;
3
+ export declare function spyReport(event: any): void;
4
+ export declare function spyReportStart(event: any): void;
5
+ export declare function spyReportEnd(change?: any): void;
6
+ export declare function spy(listener: (change: any) => void): Lambda;
package/lib/index.js ADDED
@@ -0,0 +1,7 @@
1
+
2
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
3
+ module.exports = require('./mobx.min.js');
4
+ } else {
5
+ module.exports = require('./mobx.js');
6
+ }
7
+
package/lib/internal.d.ts CHANGED
@@ -1,44 +1,44 @@
1
- export * from "./utils/utils";
2
- export * from "./utils/iterable";
3
- export * from "./core/atom";
4
- export * from "./utils/comparer";
5
- export * from "./utils/decorators2";
6
- export * from "./types/modifiers";
7
- export * from "./api/observabledecorator";
8
- export * from "./api/observable";
9
- export * from "./api/computed";
10
- export * from "./core/action";
11
- export * from "./types/observablevalue";
12
- export * from "./core/computedvalue";
13
- export * from "./core/derivation";
14
- export * from "./core/globalstate";
15
- export * from "./core/observable";
16
- export * from "./core/reaction";
17
- export * from "./core/spy";
18
- export * from "./api/actiondecorator";
19
- export * from "./api/action";
20
- export * from "./api/autorun";
21
- export * from "./api/become-observed";
22
- export * from "./api/configure";
23
- export * from "./api/decorate";
24
- export * from "./api/extendobservable";
25
- export * from "./api/extras";
26
- export * from "./api/flow";
27
- export * from "./api/intercept-read";
28
- export * from "./api/intercept";
29
- export * from "./api/iscomputed";
30
- export * from "./api/isobservable";
31
- export * from "./api/object-api";
32
- export * from "./api/observe";
33
- export * from "./api/tojs";
34
- export * from "./api/trace";
35
- export * from "./api/transaction";
36
- export * from "./api/when";
37
- export * from "./types/intercept-utils";
38
- export * from "./types/listen-utils";
39
- export * from "./types/observablearray";
40
- export * from "./types/observablemap";
41
- export * from "./types/observableset";
42
- export * from "./types/observableobject";
43
- export * from "./types/type-utils";
44
- export * from "./utils/eq";
1
+ export * from "./utils/utils";
2
+ export * from "./utils/iterable";
3
+ export * from "./core/atom";
4
+ export * from "./utils/comparer";
5
+ export * from "./utils/decorators2";
6
+ export * from "./types/modifiers";
7
+ export * from "./api/observabledecorator";
8
+ export * from "./api/observable";
9
+ export * from "./api/computed";
10
+ export * from "./core/action";
11
+ export * from "./types/observablevalue";
12
+ export * from "./core/computedvalue";
13
+ export * from "./core/derivation";
14
+ export * from "./core/globalstate";
15
+ export * from "./core/observable";
16
+ export * from "./core/reaction";
17
+ export * from "./core/spy";
18
+ export * from "./api/actiondecorator";
19
+ export * from "./api/action";
20
+ export * from "./api/autorun";
21
+ export * from "./api/become-observed";
22
+ export * from "./api/configure";
23
+ export * from "./api/decorate";
24
+ export * from "./api/extendobservable";
25
+ export * from "./api/extras";
26
+ export * from "./api/flow";
27
+ export * from "./api/intercept-read";
28
+ export * from "./api/intercept";
29
+ export * from "./api/iscomputed";
30
+ export * from "./api/isobservable";
31
+ export * from "./api/object-api";
32
+ export * from "./api/observe";
33
+ export * from "./api/tojs";
34
+ export * from "./api/trace";
35
+ export * from "./api/transaction";
36
+ export * from "./api/when";
37
+ export * from "./types/intercept-utils";
38
+ export * from "./types/listen-utils";
39
+ export * from "./types/observablearray";
40
+ export * from "./types/observablemap";
41
+ export * from "./types/observableset";
42
+ export * from "./types/observableobject";
43
+ export * from "./types/type-utils";
44
+ export * from "./utils/eq";
package/lib/mobx.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- /**
2
- * (c) Michel Weststrate 2015 - 2019
3
- * MIT Licensed
4
- *
5
- * Welcome to the mobx sources! To get an global overview of how MobX internally works,
6
- * this is a good place to start:
7
- * https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
8
- *
9
- * Source folders:
10
- * ===============
11
- *
12
- * - api/ Most of the public static methods exposed by the module can be found here.
13
- * - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
14
- * - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
15
- * - utils/ Utility stuff.
16
- *
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, FlowCancellationError, isFlowCancellationError, 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
- export declare const $mobx = "$mobx";
1
+ /**
2
+ * (c) Michel Weststrate 2015 - 2019
3
+ * MIT Licensed
4
+ *
5
+ * Welcome to the mobx sources! To get an global overview of how MobX internally works,
6
+ * this is a good place to start:
7
+ * https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
8
+ *
9
+ * Source folders:
10
+ * ===============
11
+ *
12
+ * - api/ Most of the public static methods exposed by the module can be found here.
13
+ * - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
14
+ * - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
15
+ * - utils/ Utility stuff.
16
+ *
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, FlowCancellationError, isFlowCancellationError, 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, allowStateReadsStart as _allowStateReadsStart, allowStateReadsEnd as _allowStateReadsEnd } from "./internal";
19
+ export declare const $mobx = "$mobx";