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,14 +1,14 @@
1
- import { IComputedValueOptions, IComputedValue } from "../internal";
2
- export interface IComputed {
3
- <T>(options: IComputedValueOptions<T>): any;
4
- <T>(func: () => T, setter: (v: T) => void): IComputedValue<T>;
5
- <T>(func: () => T, options?: IComputedValueOptions<T>): IComputedValue<T>;
6
- (target: Object, key: string | symbol, baseDescriptor?: PropertyDescriptor): void;
7
- struct(target: Object, key: string | symbol, baseDescriptor?: PropertyDescriptor): void;
8
- }
9
- export declare const computedDecorator: Function;
10
- /**
11
- * Decorator for class properties: @computed get value() { return expr; }.
12
- * For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
13
- */
14
- export declare const computed: IComputed;
1
+ import { IComputedValueOptions, IComputedValue } from "../internal";
2
+ export interface IComputed {
3
+ <T>(options: IComputedValueOptions<T>): any;
4
+ <T>(func: () => T, setter: (v: T) => void): IComputedValue<T>;
5
+ <T>(func: () => T, options?: IComputedValueOptions<T>): IComputedValue<T>;
6
+ (target: Object, key: string | symbol, baseDescriptor?: PropertyDescriptor): void;
7
+ struct(target: Object, key: string | symbol, baseDescriptor?: PropertyDescriptor): void;
8
+ }
9
+ export declare const computedDecorator: Function;
10
+ /**
11
+ * Decorator for class properties: @computed get value() { return expr; }.
12
+ * For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
13
+ */
14
+ export declare const computed: IComputed;
@@ -1,19 +1,19 @@
1
- export declare function configure(options: {
2
- enforceActions?: boolean | "strict" | "never" | "always" | "observed";
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;
14
- computedConfigurable?: boolean;
15
- isolateGlobalState?: boolean;
16
- disableErrorBoundaries?: boolean;
17
- arrayBuffer?: number;
18
- reactionScheduler?: (f: () => void) => void;
19
- }): void;
1
+ export declare function configure(options: {
2
+ enforceActions?: boolean | "strict" | "never" | "always" | "observed";
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;
14
+ computedConfigurable?: boolean;
15
+ isolateGlobalState?: boolean;
16
+ disableErrorBoundaries?: boolean;
17
+ arrayBuffer?: number;
18
+ reactionScheduler?: (f: () => void) => void;
19
+ }): void;
@@ -1,6 +1,6 @@
1
- export declare function decorate<T>(clazz: new (...args: any[]) => T, decorators: {
2
- [P in keyof T]?: MethodDecorator | PropertyDecorator | Array<MethodDecorator> | Array<PropertyDecorator>;
3
- }): void;
4
- export declare function decorate<T>(object: T, decorators: {
5
- [P in keyof T]?: MethodDecorator | PropertyDecorator | Array<MethodDecorator> | Array<PropertyDecorator>;
6
- }): T;
1
+ export declare function decorate<T>(clazz: new (...args: any[]) => T, decorators: {
2
+ [P in keyof T]?: MethodDecorator | PropertyDecorator | Array<MethodDecorator> | Array<PropertyDecorator>;
3
+ }): void;
4
+ export declare function decorate<T>(object: T, decorators: {
5
+ [P in keyof T]?: MethodDecorator | PropertyDecorator | Array<MethodDecorator> | Array<PropertyDecorator>;
6
+ }): T;
@@ -1,7 +1,7 @@
1
- import { CreateObservableOptions } from "../internal";
2
- export declare function extendShallowObservable<A extends Object, B extends Object>(target: A, properties: B, decorators?: {
3
- [K in keyof B]?: Function;
4
- }): A & B;
5
- export declare function extendObservable<A extends Object, B extends Object>(target: A, properties: B, decorators?: {
6
- [K in keyof B]?: Function;
7
- }, options?: CreateObservableOptions): A & B;
1
+ import { CreateObservableOptions } from "../internal";
2
+ export declare function extendShallowObservable<A extends Object, B extends Object>(target: A, properties: B, decorators?: {
3
+ [K in keyof B]?: Function;
4
+ }): A & B;
5
+ export declare function extendObservable<A extends Object, B extends Object>(target: A, properties: B, decorators?: {
6
+ [K in keyof B]?: Function;
7
+ }, options?: CreateObservableOptions): A & B;
@@ -1,10 +1,10 @@
1
- export interface IDependencyTree {
2
- name: string;
3
- dependencies?: IDependencyTree[];
4
- }
5
- export interface IObserverTree {
6
- name: string;
7
- observers?: IObserverTree[];
8
- }
9
- export declare function getDependencyTree(thing: any, property?: string): IDependencyTree;
10
- export declare function getObserverTree(thing: any, property?: string): IObserverTree;
1
+ export interface IDependencyTree {
2
+ name: string;
3
+ dependencies?: IDependencyTree[];
4
+ }
5
+ export interface IObserverTree {
6
+ name: string;
7
+ observers?: IObserverTree[];
8
+ }
9
+ export declare function getDependencyTree(thing: any, property?: string): IDependencyTree;
10
+ export declare function getObserverTree(thing: any, property?: string): IObserverTree;
package/lib/api/flow.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export declare function FlowCancellationError(): void;
2
- export declare namespace FlowCancellationError {
3
- var prototype: any;
4
- }
5
- export declare function isFlowCancellationError(error: Error): boolean;
6
- export declare type CancellablePromise<T> = Promise<T> & {
7
- cancel(): void;
8
- };
9
- export declare function flow<R, Args extends any[]>(generator: (...args: Args) => Generator<any, R, any> | AsyncGenerator<any, R, any>): (...args: Args) => CancellablePromise<R>;
1
+ export declare function FlowCancellationError(): void;
2
+ export declare namespace FlowCancellationError {
3
+ var prototype: any;
4
+ }
5
+ export declare function isFlowCancellationError(error: Error): boolean;
6
+ export declare type CancellablePromise<T> = Promise<T> & {
7
+ cancel(): void;
8
+ };
9
+ export declare function flow<R, Args extends any[]>(generator: (...args: Args) => Generator<any, R, any> | AsyncGenerator<any, R, any>): (...args: Args) => CancellablePromise<R>;
@@ -1,8 +1,8 @@
1
- import { Lambda, IObservableValue, IObservableArray, ObservableMap, ObservableSet } from "../internal";
2
- export declare type ReadInterceptor<T> = (value: any) => T;
3
- /** Experimental feature right now, tested indirectly via Mobx-State-Tree */
4
- export declare function interceptReads<T>(value: IObservableValue<T>, handler: ReadInterceptor<T>): Lambda;
5
- export declare function interceptReads<T>(observableArray: IObservableArray<T>, handler: ReadInterceptor<T>): Lambda;
6
- export declare function interceptReads<K, V>(observableMap: ObservableMap<K, V>, handler: ReadInterceptor<V>): Lambda;
7
- export declare function interceptReads<V>(observableSet: ObservableSet<V>, handler: ReadInterceptor<V>): Lambda;
8
- export declare function interceptReads(object: Object, property: string, handler: ReadInterceptor<any>): Lambda;
1
+ import { Lambda, IObservableValue, IObservableArray, ObservableMap, ObservableSet } from "../internal";
2
+ export declare type ReadInterceptor<T> = (value: any) => T;
3
+ /** Experimental feature right now, tested indirectly via Mobx-State-Tree */
4
+ export declare function interceptReads<T>(value: IObservableValue<T>, handler: ReadInterceptor<T>): Lambda;
5
+ export declare function interceptReads<T>(observableArray: IObservableArray<T>, handler: ReadInterceptor<T>): Lambda;
6
+ export declare function interceptReads<K, V>(observableMap: ObservableMap<K, V>, handler: ReadInterceptor<V>): Lambda;
7
+ export declare function interceptReads<V>(observableSet: ObservableSet<V>, handler: ReadInterceptor<V>): Lambda;
8
+ export declare function interceptReads(object: Object, property: string, handler: ReadInterceptor<any>): Lambda;
@@ -1,8 +1,8 @@
1
- import { IInterceptor, IValueWillChange, IObservableValue, Lambda, IObservableArray, IArrayWillChange, IArrayWillSplice, ObservableMap, IMapWillChange, ObservableSet, ISetWillChange, IObjectWillChange } from "../internal";
2
- export declare function intercept<T>(value: IObservableValue<T>, handler: IInterceptor<IValueWillChange<T>>): Lambda;
3
- export declare function intercept<T>(observableArray: IObservableArray<T>, handler: IInterceptor<IArrayWillChange<T> | IArrayWillSplice<T>>): Lambda;
4
- export declare function intercept<K, V>(observableMap: ObservableMap<K, V>, handler: IInterceptor<IMapWillChange<K, V>>): Lambda;
5
- export declare function intercept<V>(observableMap: ObservableSet<V>, handler: IInterceptor<ISetWillChange<V>>): Lambda;
6
- export declare function intercept<K, V>(observableMap: ObservableMap<K, V>, property: K, handler: IInterceptor<IValueWillChange<V>>): Lambda;
7
- export declare function intercept(object: Object, handler: IInterceptor<IObjectWillChange>): Lambda;
8
- export declare function intercept<T extends Object, K extends keyof T>(object: T, property: K, handler: IInterceptor<IValueWillChange<any>>): Lambda;
1
+ import { IInterceptor, IValueWillChange, IObservableValue, Lambda, IObservableArray, IArrayWillChange, IArrayWillSplice, ObservableMap, IMapWillChange, ObservableSet, ISetWillChange, IObjectWillChange } from "../internal";
2
+ export declare function intercept<T>(value: IObservableValue<T>, handler: IInterceptor<IValueWillChange<T>>): Lambda;
3
+ export declare function intercept<T>(observableArray: IObservableArray<T>, handler: IInterceptor<IArrayWillChange<T> | IArrayWillSplice<T>>): Lambda;
4
+ export declare function intercept<K, V>(observableMap: ObservableMap<K, V>, handler: IInterceptor<IMapWillChange<K, V>>): Lambda;
5
+ export declare function intercept<V>(observableMap: ObservableSet<V>, handler: IInterceptor<ISetWillChange<V>>): Lambda;
6
+ export declare function intercept<K, V>(observableMap: ObservableMap<K, V>, property: K, handler: IInterceptor<IValueWillChange<V>>): Lambda;
7
+ export declare function intercept(object: Object, handler: IInterceptor<IObjectWillChange>): Lambda;
8
+ export declare function intercept<T extends Object, K extends keyof T>(object: T, property: K, handler: IInterceptor<IValueWillChange<any>>): Lambda;
@@ -1,3 +1,3 @@
1
- export declare function _isComputed(value: any, property?: string): boolean;
2
- export declare function isComputed(value: any): boolean;
3
- export declare function isComputedProp(value: any, propName: string): boolean;
1
+ export declare function _isComputed(value: any, property?: string): boolean;
2
+ export declare function isComputed(value: any): boolean;
3
+ export declare function isComputedProp(value: any, propName: string): boolean;
@@ -1,2 +1,2 @@
1
- export declare function isObservable(value: any): boolean;
2
- export declare function isObservableProp(value: any, propName: string): boolean;
1
+ export declare function isObservable(value: any): boolean;
2
+ export declare function isObservableProp(value: any, propName: string): boolean;
@@ -1,34 +1,34 @@
1
- import { ObservableMap, IObservableArray, ObservableSet } from "../internal";
2
- export declare function keys<K>(map: ObservableMap<K, any>): ReadonlyArray<K>;
3
- export declare function keys<T>(ar: IObservableArray<T>): ReadonlyArray<number>;
4
- export declare function keys<T>(set: ObservableSet<T>): ReadonlyArray<T>;
5
- export declare function keys<T extends Object>(obj: T): ReadonlyArray<string>;
6
- export declare function values<K, T>(map: ObservableMap<K, T>): ReadonlyArray<T>;
7
- export declare function values<T>(set: ObservableSet<T>): ReadonlyArray<T>;
8
- export declare function values<T>(ar: IObservableArray<T>): ReadonlyArray<T>;
9
- export declare function values<T = any>(obj: T): ReadonlyArray<any>;
10
- export declare function entries<K, T>(map: ObservableMap<K, T>): ReadonlyArray<[K, T]>;
11
- export declare function entries<T>(set: ObservableSet<T>): ReadonlyArray<[T, T]>;
12
- export declare function entries<T>(ar: IObservableArray<T>): ReadonlyArray<[number, T]>;
13
- export declare function entries<T = any>(obj: T): ReadonlyArray<[string, any]>;
14
- export declare function set<V>(obj: ObservableMap<string, V>, values: {
15
- [key: string]: V;
16
- }): any;
17
- export declare function set<K, V>(obj: ObservableMap<K, V>, key: K, value: V): any;
18
- export declare function set<T>(obj: ObservableSet<T>, value: T): any;
19
- export declare function set<T>(obj: IObservableArray<T>, index: number, value: T): any;
20
- export declare function set<T extends Object>(obj: T, values: {
21
- [key: string]: any;
22
- }): any;
23
- export declare function set<T extends Object>(obj: T, key: string, value: any): any;
24
- export declare function remove<K, V>(obj: ObservableMap<K, V>, key: K): any;
25
- export declare function remove<T>(obj: ObservableSet<T>, key: T): any;
26
- export declare function remove<T>(obj: IObservableArray<T>, index: number): any;
27
- export declare function remove<T extends Object>(obj: T, key: string): any;
28
- export declare function has<K>(obj: ObservableMap<K, any>, key: K): boolean;
29
- export declare function has<T>(obj: ObservableSet<T>, key: T): boolean;
30
- export declare function has<T>(obj: IObservableArray<T>, index: number): boolean;
31
- export declare function has<T extends Object>(obj: T, key: string): boolean;
32
- export declare function get<K, V>(obj: ObservableMap<K, V>, key: K): V | undefined;
33
- export declare function get<T>(obj: IObservableArray<T>, index: number): T | undefined;
34
- export declare function get<T extends Object>(obj: T, key: string): any;
1
+ import { ObservableMap, IObservableArray, ObservableSet } from "../internal";
2
+ export declare function keys<K>(map: ObservableMap<K, any>): ReadonlyArray<K>;
3
+ export declare function keys<T>(ar: IObservableArray<T>): ReadonlyArray<number>;
4
+ export declare function keys<T>(set: ObservableSet<T>): ReadonlyArray<T>;
5
+ export declare function keys<T extends Object>(obj: T): ReadonlyArray<string>;
6
+ export declare function values<K, T>(map: ObservableMap<K, T>): ReadonlyArray<T>;
7
+ export declare function values<T>(set: ObservableSet<T>): ReadonlyArray<T>;
8
+ export declare function values<T>(ar: IObservableArray<T>): ReadonlyArray<T>;
9
+ export declare function values<T = any>(obj: T): ReadonlyArray<any>;
10
+ export declare function entries<K, T>(map: ObservableMap<K, T>): ReadonlyArray<[K, T]>;
11
+ export declare function entries<T>(set: ObservableSet<T>): ReadonlyArray<[T, T]>;
12
+ export declare function entries<T>(ar: IObservableArray<T>): ReadonlyArray<[number, T]>;
13
+ export declare function entries<T = any>(obj: T): ReadonlyArray<[string, any]>;
14
+ export declare function set<V>(obj: ObservableMap<string, V>, values: {
15
+ [key: string]: V;
16
+ }): any;
17
+ export declare function set<K, V>(obj: ObservableMap<K, V>, key: K, value: V): any;
18
+ export declare function set<T>(obj: ObservableSet<T>, value: T): any;
19
+ export declare function set<T>(obj: IObservableArray<T>, index: number, value: T): any;
20
+ export declare function set<T extends Object>(obj: T, values: {
21
+ [key: string]: any;
22
+ }): any;
23
+ export declare function set<T extends Object>(obj: T, key: string, value: any): any;
24
+ export declare function remove<K, V>(obj: ObservableMap<K, V>, key: K): any;
25
+ export declare function remove<T>(obj: ObservableSet<T>, key: T): any;
26
+ export declare function remove<T>(obj: IObservableArray<T>, index: number): any;
27
+ export declare function remove<T extends Object>(obj: T, key: string): any;
28
+ export declare function has<K>(obj: ObservableMap<K, any>, key: K): boolean;
29
+ export declare function has<T>(obj: ObservableSet<T>, key: T): boolean;
30
+ export declare function has<T>(obj: IObservableArray<T>, index: number): boolean;
31
+ export declare function has<T extends Object>(obj: T, key: string): boolean;
32
+ export declare function get<K, V>(obj: ObservableMap<K, V>, key: K): V | undefined;
33
+ export declare function get<T>(obj: IObservableArray<T>, index: number): T | undefined;
34
+ export declare function get<T extends Object>(obj: T, key: string): any;
@@ -1,54 +1,54 @@
1
- import { IEqualsComparer, IObservableDecorator, IEnhancer, IObservableArray, ObservableMap, IObservableObject, IObservableValue, IObservableSetInitialValues, ObservableSet, IObservableMapInitialValues } from "../internal";
2
- export declare type CreateObservableOptions = {
3
- name?: string;
4
- equals?: IEqualsComparer<any>;
5
- deep?: boolean;
6
- defaultDecorator?: IObservableDecorator;
7
- };
8
- export declare const defaultCreateObservableOptions: CreateObservableOptions;
9
- export declare const shallowCreateObservableOptions: {
10
- deep: boolean;
11
- name: undefined;
12
- defaultDecorator: undefined;
13
- };
14
- export declare function asCreateObservableOptions(thing: any): CreateObservableOptions;
15
- export declare const deepDecorator: IObservableDecorator;
16
- export declare const refDecorator: IObservableDecorator;
17
- export interface IObservableFactory {
18
- (value: number | string | null | undefined | boolean): never;
19
- (target: Object, key: string | symbol, baseDescriptor?: PropertyDescriptor): any;
20
- <T = any>(value: T[], options?: CreateObservableOptions): IObservableArray<T>;
21
- <T = any>(value: Set<T>, options?: CreateObservableOptions): ObservableSet<T>;
22
- <K = any, V = any>(value: Map<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
23
- <T extends Object>(value: T, decorators?: {
24
- [K in keyof T]?: Function;
25
- }, options?: CreateObservableOptions): T & IObservableObject;
26
- }
27
- export interface IObservableFactories {
28
- box<T = any>(value?: T, options?: CreateObservableOptions): IObservableValue<T>;
29
- shallowBox<T = any>(value?: T, options?: CreateObservableOptions): IObservableValue<T>;
30
- array<T = any>(initialValues?: T[], options?: CreateObservableOptions): IObservableArray<T>;
31
- shallowArray<T = any>(initialValues?: T[], options?: CreateObservableOptions): IObservableArray<T>;
32
- set<T = any>(initialValues?: IObservableSetInitialValues<T>, options?: CreateObservableOptions): ObservableSet<T>;
33
- map<K = any, V = any>(initialValues?: IObservableMapInitialValues<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
34
- shallowMap<K = any, V = any>(initialValues?: IObservableMapInitialValues<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
35
- object<T = any>(props: T, decorators?: {
36
- [K in keyof T]?: Function;
37
- }, options?: CreateObservableOptions): T & IObservableObject;
38
- shallowObject<T = any>(props: T, decorators?: {
39
- [K in keyof T]?: Function;
40
- }, options?: CreateObservableOptions): T & IObservableObject;
41
- /**
42
- * Decorator that creates an observable that only observes the references, but doesn't try to turn the assigned value into an observable.ts.
43
- */
44
- ref: IObservableDecorator;
45
- /**
46
- * Decorator that creates an observable converts its value (objects, maps or arrays) into a shallow observable structure
47
- */
48
- shallow: IObservableDecorator;
49
- deep: IObservableDecorator;
50
- struct: IObservableDecorator;
51
- }
52
- export declare const observable: IObservableFactory & IObservableFactories & {
53
- enhancer: IEnhancer<any>;
54
- };
1
+ import { IEqualsComparer, IObservableDecorator, IEnhancer, IObservableArray, ObservableMap, IObservableObject, IObservableValue, IObservableSetInitialValues, ObservableSet, IObservableMapInitialValues } from "../internal";
2
+ export declare type CreateObservableOptions = {
3
+ name?: string;
4
+ equals?: IEqualsComparer<any>;
5
+ deep?: boolean;
6
+ defaultDecorator?: IObservableDecorator;
7
+ };
8
+ export declare const defaultCreateObservableOptions: CreateObservableOptions;
9
+ export declare const shallowCreateObservableOptions: {
10
+ deep: boolean;
11
+ name: undefined;
12
+ defaultDecorator: undefined;
13
+ };
14
+ export declare function asCreateObservableOptions(thing: any): CreateObservableOptions;
15
+ export declare const deepDecorator: IObservableDecorator;
16
+ export declare const refDecorator: IObservableDecorator;
17
+ export interface IObservableFactory {
18
+ (value: number | string | null | undefined | boolean): never;
19
+ (target: Object, key: string | symbol, baseDescriptor?: PropertyDescriptor): any;
20
+ <T = any>(value: T[], options?: CreateObservableOptions): IObservableArray<T>;
21
+ <T = any>(value: Set<T>, options?: CreateObservableOptions): ObservableSet<T>;
22
+ <K = any, V = any>(value: Map<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
23
+ <T extends Object>(value: T, decorators?: {
24
+ [K in keyof T]?: Function;
25
+ }, options?: CreateObservableOptions): T & IObservableObject;
26
+ }
27
+ export interface IObservableFactories {
28
+ box<T = any>(value?: T, options?: CreateObservableOptions): IObservableValue<T>;
29
+ shallowBox<T = any>(value?: T, options?: CreateObservableOptions): IObservableValue<T>;
30
+ array<T = any>(initialValues?: T[], options?: CreateObservableOptions): IObservableArray<T>;
31
+ shallowArray<T = any>(initialValues?: T[], options?: CreateObservableOptions): IObservableArray<T>;
32
+ set<T = any>(initialValues?: IObservableSetInitialValues<T>, options?: CreateObservableOptions): ObservableSet<T>;
33
+ map<K = any, V = any>(initialValues?: IObservableMapInitialValues<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
34
+ shallowMap<K = any, V = any>(initialValues?: IObservableMapInitialValues<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
35
+ object<T = any>(props: T, decorators?: {
36
+ [K in keyof T]?: Function;
37
+ }, options?: CreateObservableOptions): T & IObservableObject;
38
+ shallowObject<T = any>(props: T, decorators?: {
39
+ [K in keyof T]?: Function;
40
+ }, options?: CreateObservableOptions): T & IObservableObject;
41
+ /**
42
+ * Decorator that creates an observable that only observes the references, but doesn't try to turn the assigned value into an observable.ts.
43
+ */
44
+ ref: IObservableDecorator;
45
+ /**
46
+ * Decorator that creates an observable converts its value (objects, maps or arrays) into a shallow observable structure
47
+ */
48
+ shallow: IObservableDecorator;
49
+ deep: IObservableDecorator;
50
+ struct: IObservableDecorator;
51
+ }
52
+ export declare const observable: IObservableFactory & IObservableFactories & {
53
+ enhancer: IEnhancer<any>;
54
+ };
@@ -1,6 +1,6 @@
1
- import { IEnhancer } from "../internal";
2
- export declare type IObservableDecorator = {
3
- (target: Object, property: string | symbol, descriptor?: PropertyDescriptor): void;
4
- enhancer: IEnhancer<any>;
5
- };
6
- export declare function createDecoratorForEnhancer(enhancer: IEnhancer<any>): IObservableDecorator;
1
+ import { IEnhancer } from "../internal";
2
+ export declare type IObservableDecorator = {
3
+ (target: Object, property: string | symbol, descriptor?: PropertyDescriptor): void;
4
+ enhancer: IEnhancer<any>;
5
+ };
6
+ export declare function createDecoratorForEnhancer(enhancer: IEnhancer<any>): IObservableDecorator;
@@ -1,8 +1,8 @@
1
- import { IObservableArray, IArrayChange, IArraySplice, IObservableValue, IComputedValue, IValueDidChange, Lambda, ObservableSet, ISetDidChange, ObservableMap, IMapDidChange, IObjectDidChange } from "../internal";
2
- export declare function observe<T>(value: IObservableValue<T> | IComputedValue<T>, listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean): Lambda;
3
- export declare function observe<T>(observableArray: IObservableArray<T>, listener: (change: IArrayChange<T> | IArraySplice<T>) => void, fireImmediately?: boolean): Lambda;
4
- export declare function observe<V>(observableMap: ObservableSet<V>, listener: (change: ISetDidChange<V>) => void, fireImmediately?: boolean): Lambda;
5
- export declare function observe<K, V>(observableMap: ObservableMap<K, V>, listener: (change: IMapDidChange<K, V>) => void, fireImmediately?: boolean): Lambda;
6
- export declare function observe<K, V>(observableMap: ObservableMap<K, V>, property: K, listener: (change: IValueDidChange<V>) => void, fireImmediately?: boolean): Lambda;
7
- export declare function observe(object: Object, listener: (change: IObjectDidChange) => void, fireImmediately?: boolean): Lambda;
8
- export declare function observe<T, K extends keyof T>(object: T, property: K, listener: (change: IValueDidChange<T[K]>) => void, fireImmediately?: boolean): Lambda;
1
+ import { IObservableArray, IArrayChange, IArraySplice, IObservableValue, IComputedValue, IValueDidChange, Lambda, ObservableSet, ISetDidChange, ObservableMap, IMapDidChange, IObjectDidChange } from "../internal";
2
+ export declare function observe<T>(value: IObservableValue<T> | IComputedValue<T>, listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean): Lambda;
3
+ export declare function observe<T>(observableArray: IObservableArray<T>, listener: (change: IArrayChange<T> | IArraySplice<T>) => void, fireImmediately?: boolean): Lambda;
4
+ export declare function observe<V>(observableMap: ObservableSet<V>, listener: (change: ISetDidChange<V>) => void, fireImmediately?: boolean): Lambda;
5
+ export declare function observe<K, V>(observableMap: ObservableMap<K, V>, listener: (change: IMapDidChange<K, V>) => void, fireImmediately?: boolean): Lambda;
6
+ export declare function observe<K, V>(observableMap: ObservableMap<K, V>, property: K, listener: (change: IValueDidChange<V>) => void, fireImmediately?: boolean): Lambda;
7
+ export declare function observe(object: Object, listener: (change: IObjectDidChange) => void, fireImmediately?: boolean): Lambda;
8
+ export declare function observe<T, K extends keyof T>(object: T, property: K, listener: (change: IValueDidChange<T[K]>) => void, fireImmediately?: boolean): Lambda;
package/lib/api/tojs.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export declare type ToJSOptions = {
2
- detectCycles?: boolean;
3
- exportMapsAsObjects?: boolean;
4
- recurseEverything?: boolean;
5
- };
6
- /**
7
- * Basically, a deep clone, so that no reactive property will exist anymore.
8
- */
9
- export declare function toJS<T>(source: T, options?: ToJSOptions): T;
10
- export declare function toJS(source: any, options?: ToJSOptions): any;
11
- export declare function toJS(source: any, options: ToJSOptions): any;
1
+ export declare type ToJSOptions = {
2
+ detectCycles?: boolean;
3
+ exportMapsAsObjects?: boolean;
4
+ recurseEverything?: boolean;
5
+ };
6
+ /**
7
+ * Basically, a deep clone, so that no reactive property will exist anymore.
8
+ */
9
+ export declare function toJS<T>(source: T, options?: ToJSOptions): T;
10
+ export declare function toJS(source: any, options?: ToJSOptions): any;
11
+ export declare function toJS(source: any, options: ToJSOptions): any;
@@ -1,3 +1,3 @@
1
- export declare function trace(thing?: any, prop?: string, enterBreakPoint?: boolean): void;
2
- export declare function trace(thing?: any, enterBreakPoint?: boolean): void;
3
- export declare function trace(enterBreakPoint?: boolean): void;
1
+ export declare function trace(thing?: any, prop?: string, enterBreakPoint?: boolean): void;
2
+ export declare function trace(thing?: any, enterBreakPoint?: boolean): void;
3
+ export declare function trace(enterBreakPoint?: boolean): void;
@@ -1,8 +1,8 @@
1
- /**
2
- * During a transaction no views are updated until the end of the transaction.
3
- * The transaction will be run synchronously nonetheless.
4
- *
5
- * @param action a function that updates some reactive state
6
- * @returns any value that was returned by the 'action' parameter.
7
- */
8
- export declare function transaction<T>(action: () => T, thisArg?: undefined): T;
1
+ /**
2
+ * During a transaction no views are updated until the end of the transaction.
3
+ * The transaction will be run synchronously nonetheless.
4
+ *
5
+ * @param action a function that updates some reactive state
6
+ * @returns any value that was returned by the 'action' parameter.
7
+ */
8
+ export declare function transaction<T>(action: () => T, thisArg?: undefined): T;
package/lib/api/when.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { Lambda, IReactionDisposer } from "../internal";
2
- export interface IWhenOptions {
3
- name?: string;
4
- timeout?: number;
5
- /**
6
- * Experimental.
7
- * Warns if the view doesn't track observables
8
- */
9
- requiresObservable?: boolean;
10
- onError?: (error: any) => void;
11
- }
12
- export declare function when(predicate: () => boolean, opts?: IWhenOptions): Promise<void> & {
13
- cancel(): void;
14
- };
15
- export declare function when(predicate: () => boolean, effect: Lambda, opts?: IWhenOptions): IReactionDisposer;
1
+ import { Lambda, IReactionDisposer } from "../internal";
2
+ export interface IWhenOptions {
3
+ name?: string;
4
+ timeout?: number;
5
+ /**
6
+ * Experimental.
7
+ * Warns if the view doesn't track observables
8
+ */
9
+ requiresObservable?: boolean;
10
+ onError?: (error: any) => void;
11
+ }
12
+ export declare function when(predicate: () => boolean, opts?: IWhenOptions): Promise<void> & {
13
+ cancel(): void;
14
+ };
15
+ export declare function when(predicate: () => boolean, effect: Lambda, opts?: IWhenOptions): IReactionDisposer;
@@ -1,22 +1,22 @@
1
- import { IDerivation } from "../internal";
2
- export interface IAction {
3
- isMobxAction: boolean;
4
- }
5
- export declare function createAction(actionName: string, fn: Function): Function & IAction;
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;
19
- export declare function allowStateChanges<T>(allowStateChanges: boolean, func: () => T): T;
20
- export declare function allowStateChangesStart(allowStateChanges: boolean): boolean;
21
- export declare function allowStateChangesEnd(prev: boolean): void;
22
- export declare function allowStateChangesInsideComputed<T>(func: () => T): T;
1
+ import { IDerivation } from "../internal";
2
+ export interface IAction {
3
+ isMobxAction: boolean;
4
+ }
5
+ export declare function createAction(actionName: string, fn: Function): Function & IAction;
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;
19
+ export declare function allowStateChanges<T>(allowStateChanges: boolean, func: () => T): T;
20
+ export declare function allowStateChangesStart(allowStateChanges: boolean): boolean;
21
+ export declare function allowStateChangesEnd(prev: boolean): void;
22
+ export declare function allowStateChangesInsideComputed<T>(func: () => T): T;
@@ -1,40 +1,40 @@
1
- import { IObservable, IDerivationState } from "../internal";
2
- export interface IAtom extends IObservable {
3
- reportObserved(): any;
4
- reportChanged(): any;
5
- }
6
- /**
7
- * Anything that can be used to _store_ state is an Atom in mobx. Atoms have two important jobs
8
- *
9
- * 1) detect when they are being _used_ and report this (using reportObserved). This allows mobx to make the connection between running functions and the data they used
10
- * 2) they should notify mobx whenever they have _changed_. This way mobx can re-run any functions (derivations) that are using this atom.
11
- */
12
- export declare class Atom implements IAtom {
13
- name: string;
14
- isPendingUnobservation: boolean;
15
- isBeingObserved: boolean;
16
- observers: never[];
17
- observersIndexes: {};
18
- diffValue: number;
19
- lastAccessedBy: number;
20
- lowestObserverState: IDerivationState;
21
- /**
22
- * Create a new atom. For debugging purposes it is recommended to give it a name.
23
- * The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
24
- */
25
- constructor(name?: string);
26
- onBecomeUnobserved(): void;
27
- onBecomeObserved(): void;
28
- /**
29
- * Invoke this method to notify mobx that your atom has been used somehow.
30
- * Returns true if there is currently a reactive context.
31
- */
32
- reportObserved(): boolean;
33
- /**
34
- * Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
35
- */
36
- reportChanged(): void;
37
- toString(): string;
38
- }
39
- export declare const isAtom: (x: any) => x is Atom;
40
- export declare function createAtom(name: string, onBecomeObservedHandler?: () => void, onBecomeUnobservedHandler?: () => void): IAtom;
1
+ import { IObservable, IDerivationState } from "../internal";
2
+ export interface IAtom extends IObservable {
3
+ reportObserved(): any;
4
+ reportChanged(): any;
5
+ }
6
+ /**
7
+ * Anything that can be used to _store_ state is an Atom in mobx. Atoms have two important jobs
8
+ *
9
+ * 1) detect when they are being _used_ and report this (using reportObserved). This allows mobx to make the connection between running functions and the data they used
10
+ * 2) they should notify mobx whenever they have _changed_. This way mobx can re-run any functions (derivations) that are using this atom.
11
+ */
12
+ export declare class Atom implements IAtom {
13
+ name: string;
14
+ isPendingUnobservation: boolean;
15
+ isBeingObserved: boolean;
16
+ observers: never[];
17
+ observersIndexes: {};
18
+ diffValue: number;
19
+ lastAccessedBy: number;
20
+ lowestObserverState: IDerivationState;
21
+ /**
22
+ * Create a new atom. For debugging purposes it is recommended to give it a name.
23
+ * The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
24
+ */
25
+ constructor(name?: string);
26
+ onBecomeUnobserved(): void;
27
+ onBecomeObserved(): void;
28
+ /**
29
+ * Invoke this method to notify mobx that your atom has been used somehow.
30
+ * Returns true if there is currently a reactive context.
31
+ */
32
+ reportObserved(): boolean;
33
+ /**
34
+ * Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
35
+ */
36
+ reportChanged(): void;
37
+ toString(): string;
38
+ }
39
+ export declare const isAtom: (x: any) => x is Atom;
40
+ export declare function createAtom(name: string, onBecomeObservedHandler?: () => void, onBecomeUnobservedHandler?: () => void): IAtom;