mobx 5.13.1 → 5.14.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/LICENSE +0 -0
  3. package/README.md +0 -0
  4. package/lib/api/action.d.ts +0 -0
  5. package/lib/api/actiondecorator.d.ts +0 -0
  6. package/lib/api/autorun.d.ts +5 -0
  7. package/lib/api/become-observed.d.ts +0 -0
  8. package/lib/api/computed.d.ts +0 -0
  9. package/lib/api/configure.d.ts +10 -0
  10. package/lib/api/decorate.d.ts +0 -0
  11. package/lib/api/extendobservable.d.ts +0 -0
  12. package/lib/api/extras.d.ts +0 -0
  13. package/lib/api/flow.d.ts +0 -0
  14. package/lib/api/intercept-read.d.ts +0 -0
  15. package/lib/api/intercept.d.ts +0 -0
  16. package/lib/api/iscomputed.d.ts +0 -0
  17. package/lib/api/isobservable.d.ts +0 -0
  18. package/lib/api/object-api.d.ts +0 -0
  19. package/lib/api/observable.d.ts +0 -0
  20. package/lib/api/observabledecorator.d.ts +0 -0
  21. package/lib/api/observe.d.ts +0 -0
  22. package/lib/api/tojs.d.ts +0 -0
  23. package/lib/api/trace.d.ts +0 -0
  24. package/lib/api/transaction.d.ts +0 -0
  25. package/lib/api/when.d.ts +5 -0
  26. package/lib/core/action.d.ts +1 -0
  27. package/lib/core/atom.d.ts +0 -0
  28. package/lib/core/computedvalue.d.ts +0 -0
  29. package/lib/core/derivation.d.ts +7 -0
  30. package/lib/core/globalstate.d.ts +15 -0
  31. package/lib/core/observable.d.ts +0 -0
  32. package/lib/core/reaction.d.ts +2 -1
  33. package/lib/core/spy.d.ts +0 -0
  34. package/lib/internal.d.ts +0 -0
  35. package/lib/mobx.d.ts +0 -0
  36. package/lib/mobx.es6.js +303 -246
  37. package/lib/mobx.js +304 -246
  38. package/lib/mobx.js.flow +18 -0
  39. package/lib/mobx.min.js +1 -1
  40. package/lib/mobx.module.js +305 -247
  41. package/lib/mobx.umd.js +304 -246
  42. package/lib/mobx.umd.min.js +1 -1
  43. package/lib/types/dynamicobject.d.ts +0 -0
  44. package/lib/types/intercept-utils.d.ts +0 -0
  45. package/lib/types/listen-utils.d.ts +0 -0
  46. package/lib/types/modifiers.d.ts +0 -0
  47. package/lib/types/observablearray.d.ts +0 -0
  48. package/lib/types/observablemap.d.ts +0 -0
  49. package/lib/types/observableobject.d.ts +0 -0
  50. package/lib/types/observableset.d.ts +0 -0
  51. package/lib/types/observablevalue.d.ts +0 -0
  52. package/lib/types/type-utils.d.ts +0 -0
  53. package/lib/utils/comparer.d.ts +0 -0
  54. package/lib/utils/decorators.d.ts +0 -0
  55. package/lib/utils/eq.d.ts +0 -0
  56. package/lib/utils/iterable.d.ts +0 -0
  57. package/lib/utils/utils.d.ts +0 -0
  58. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
- # 5.13.1 / 4.13.1 (TO BE RELEASED)
1
+ # 5.14.0 / 4.14.0
2
+
3
+ * Added experimental `reactionRequiresObservable` & `observableRequiresReaction` config [#2079](https://github.com/mobxjs/mobx/pull/2079), [Docs](https://github.com/mobxjs/mobx/pull/2082)
4
+ * Added experimental `requiresObservable` config to `reaction`, `autorun` & `when` options [#2079](https://github.com/mobxjs/mobx/pull/2079), [Docs](https://github.com/mobxjs/mobx/pull/2082)
5
+
6
+ # 5.13.1 / 4.13.1
2
7
 
3
8
  * Don't use `global` and `self` keywords unless defined. Fixes [#2070](https://github.com/mobxjs/mobx/issues/2070).
4
9
  * onBecome(Un)Observed didn't trigger when using number as key of observable map. Fixes [#2067](https://github.com/mobxjs/mobx/issues/2067).
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
File without changes
File without changes
@@ -2,6 +2,11 @@ import { IEqualsComparer, IReactionDisposer, IReactionPublic } 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
  }
File without changes
File without changes
@@ -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;
File without changes
File without changes
File without changes
package/lib/api/flow.d.ts CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/lib/api/tojs.d.ts CHANGED
File without changes
File without changes
File without changes
package/lib/api/when.d.ts CHANGED
@@ -2,6 +2,11 @@ import { IReactionDisposer, Lambda } 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> & {
@@ -7,6 +7,7 @@ export declare function executeAction(actionName: string, fn: Function, scope?:
7
7
  export interface IActionRunInfo {
8
8
  prevDerivation: IDerivation | null;
9
9
  prevAllowStateChanges: boolean;
10
+ prevAllowStateReads: boolean;
10
11
  notifySpy: boolean;
11
12
  startTime: number;
12
13
  error?: any;
File without changes
File without changes
@@ -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
File without changes
@@ -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/core/spy.d.ts CHANGED
File without changes
package/lib/internal.d.ts CHANGED
File without changes
package/lib/mobx.d.ts CHANGED
File without changes