UNPKG

12.7 kBTypeScriptView Raw
1/**
2 * (c) Michel Weststrate 2015 - 2016
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 */
18export { IObservable, IDepTreeNode } from "./core/observable";
19export { Reaction, IReactionPublic, IReactionDisposer } from "./core/reaction";
20export { IDerivation, untracked, IDerivationState } from "./core/derivation";
21export { IAtom, Atom, BaseAtom } from "./core/atom";
22export { useStrict, isStrictModeEnabled, IAction } from "./core/action";
23export { spy } from "./core/spy";
24export { IComputedValue } from "./core/computedvalue";
25export { IEqualsComparer, comparer } from "./types/comparer";
26export { asReference, asFlat, asStructure, asMap } from "./types/modifiers-old";
27export { IModifierDescriptor, IEnhancer, isModifierDescriptor } from "./types/modifiers";
28export { IInterceptable, IInterceptor } from "./types/intercept-utils";
29export { IListenable } from "./types/listen-utils";
30export { IObjectWillChange, IObjectChange, IObservableObject, isObservableObject } from "./types/observableobject";
31export { IValueDidChange, IValueWillChange, IObservableValue, isObservableValue as isBoxedObservable } from "./types/observablevalue";
32export { IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice, isObservableArray } from "./types/observablearray";
33export { IKeyValueMap, ObservableMap, IMapEntries, IMapEntry, IMapWillChange, IMapChange, IMapChangeUpdate, IMapChangeAdd, IMapChangeBase, IMapChangeDelete, isObservableMap, map, IObservableMapInitialValues, IMap } from "./types/observablemap";
34export { transaction } from "./api/transaction";
35export { observable, IObservableFactory, IObservableFactories } from "./api/observable";
36export { computed, IComputed, IComputedValueOptions } from "./api/computed";
37export { isObservable } from "./api/isobservable";
38export { isComputed } from "./api/iscomputed";
39export { extendObservable, extendShallowObservable } from "./api/extendobservable";
40export { observe } from "./api/observe";
41export { intercept } from "./api/intercept";
42export { autorun, autorunAsync, when, reaction, IReactionOptions } from "./api/autorun";
43export { action, isAction, runInAction, IActionFactory } from "./api/action";
44export { expr } from "./api/expr";
45export { toJS } from "./api/tojs";
46export { ITransformer, createTransformer } from "./api/createtransformer";
47export { whyRun } from "./api/whyrun";
48export { Lambda, isArrayLike } from "./utils/utils";
49export { Iterator } from "./utils/iterable";
50export { IObserverTree, IDependencyTree } from "./api/extras";
51import { IDerivation } from "./core/derivation";
52import { IDepTreeNode } from "./core/observable";
53import { IObserverTree, IDependencyTree } from "./api/extras";
54import { Lambda } from "./utils/utils";
55import { IObservableArray } from "./types/observablearray";
56import { ObservableMap } from "./types/observablemap";
57import { IObservableValue } from "./types/observablevalue";
58export declare const extras: {
59 allowStateChanges: <T>(allowStateChanges: boolean, func: () => T) => T;
60 deepEqual: (a: any, b: any) => any;
61 getAtom: (thing: any, property?: string | undefined) => IDepTreeNode;
62 getDebugName: (thing: any, property?: string | undefined) => string;
63 getDependencyTree: (thing: any, property?: string | undefined) => IDependencyTree;
64 getAdministration: (thing: any, property?: string | undefined) => any;
65 getGlobalState: () => any;
66 getObserverTree: (thing: any, property?: string | undefined) => IObserverTree;
67 interceptReads: {
68 <T>(value: IObservableValue<T>, handler: (value: any) => T): Lambda;
69 <T>(observableArray: IObservableArray<T>, handler: (value: any) => T): Lambda;
70 <T>(observableMap: ObservableMap<T>, handler: (value: any) => T): Lambda;
71 (object: Object, property: string, handler: (value: any) => any): Lambda;
72 };
73 isComputingDerivation: () => boolean;
74 isSpyEnabled: () => boolean;
75 onReactionError: (handler: (error: any, derivation: IDerivation) => void) => () => void;
76 reserveArrayBuffer: (max: number) => void;
77 resetGlobalState: () => void;
78 isolateGlobalState: () => void;
79 shareGlobalState: () => void;
80 spyReport: (event: any) => void;
81 spyReportEnd: (change?: any) => void;
82 spyReportStart: (event: any) => void;
83 setReactionScheduler: (fn: (f: () => void) => void) => void;
84};
85import { Reaction, IReactionPublic, IReactionDisposer } from "./core/reaction";
86import { Atom, BaseAtom } from "./core/atom";
87import { IComputedValue } from "./core/computedvalue";
88import { IModifierDescriptor } from "./types/modifiers";
89import { IInterceptor } from "./types/intercept-utils";
90import { IObjectWillChange, IObjectChange, IObservableObject } from "./types/observableobject";
91import { IValueDidChange, IValueWillChange } from "./types/observablevalue";
92import { IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice } from "./types/observablearray";
93import { IKeyValueMap, IMapWillChange, IMapChange, IMap } from "./types/observablemap";
94import { IObservableFactory, IObservableFactories } from "./api/observable";
95import { IComputed } from "./api/computed";
96import { IReactionOptions } from "./api/autorun";
97import { IActionFactory } from "./api/action";
98import { ITransformer } from "./api/createtransformer";
99declare const everything: {
100 Reaction: typeof Reaction;
101 untracked: <T>(action: () => T) => T;
102 Atom: typeof Atom;
103 BaseAtom: typeof BaseAtom;
104 useStrict: (strict: boolean) => void;
105 isStrictModeEnabled: () => boolean;
106 spy: (listener: (change: any) => void) => Lambda;
107 comparer: {
108 identity: (a: any, b: any) => boolean;
109 structural: (a: any, b: any) => boolean;
110 default: (a: any, b: any) => boolean;
111 };
112 asReference: <T>(value: T) => T;
113 asFlat: <T>(value: T) => T;
114 asStructure: <T>(value: T) => T;
115 asMap: {
116 (): ObservableMap<any>;
117 <T>(): ObservableMap<T>;
118 <T>(entries: [string, T][]): ObservableMap<T>;
119 <T>(data: IKeyValueMap<T>): ObservableMap<T>;
120 };
121 isModifierDescriptor: (thing: any) => thing is IModifierDescriptor<any>;
122 isObservableObject: (thing: any) => thing is IObservableObject;
123 isBoxedObservable: (x: any) => x is IObservableValue<any>;
124 isObservableArray: (thing: any) => thing is IObservableArray<any>;
125 ObservableMap: typeof ObservableMap;
126 isObservableMap: (thing: any) => thing is ObservableMap<any>;
127 map: <V>(initialValues?: [string, V][] | IKeyValueMap<V> | IMap<string, V> | undefined) => ObservableMap<V>;
128 transaction: <T>(action: () => T, thisArg?: undefined) => T;
129 observable: IObservableFactory & IObservableFactories & {
130 deep: {
131 struct<T>(initialValue?: T | undefined): T;
132 };
133 ref: {
134 struct<T>(initialValue?: T | undefined): T;
135 };
136 };
137 computed: IComputed;
138 isObservable: (value: any, property?: string | undefined) => boolean;
139 isComputed: (value: any, property?: string | undefined) => boolean;
140 extendObservable: <A extends Object, B extends Object>(target: A, ...properties: B[]) => A & B;
141 extendShallowObservable: <A extends Object, B extends Object>(target: A, ...properties: B[]) => A & B;
142 observe: {
143 <T>(value: IObservableValue<T> | IComputedValue<T>, listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean | undefined): Lambda;
144 <T>(observableArray: IObservableArray<T>, listener: (change: IArrayChange<T> | IArraySplice<T>) => void, fireImmediately?: boolean | undefined): Lambda;
145 <T>(observableMap: ObservableMap<T>, listener: (change: IMapChange<T>) => void, fireImmediately?: boolean | undefined): Lambda;
146 <T>(observableMap: ObservableMap<T>, property: string, listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean | undefined): Lambda;
147 (object: Object, listener: (change: IObjectChange) => void, fireImmediately?: boolean | undefined): Lambda;
148 (object: Object, property: string, listener: (change: IValueDidChange<any>) => void, fireImmediately?: boolean | undefined): Lambda;
149 };
150 intercept: {
151 <T>(value: IObservableValue<T>, handler: IInterceptor<IValueWillChange<T>>): Lambda;
152 <T>(observableArray: IObservableArray<T>, handler: IInterceptor<IArrayWillChange<T> | IArrayWillSplice<T>>): Lambda;
153 <T>(observableMap: ObservableMap<T>, handler: IInterceptor<IMapWillChange<T>>): Lambda;
154 <T>(observableMap: ObservableMap<T>, property: string, handler: IInterceptor<IValueWillChange<T>>): Lambda;
155 (object: Object, handler: IInterceptor<IObjectWillChange>): Lambda;
156 <T extends Object, K extends keyof T>(object: T, property: K, handler: IInterceptor<IValueWillChange<any>>): Lambda;
157 };
158 autorun: {
159 (view: (r: IReactionPublic) => any, scope?: any): IReactionDisposer;
160 (name: string, view: (r: IReactionPublic) => any, scope?: any): IReactionDisposer;
161 };
162 autorunAsync: {
163 (name: string, func: (r: IReactionPublic) => any, delay?: number | undefined, scope?: any): IReactionDisposer;
164 (func: (r: IReactionPublic) => any, delay?: number | undefined, scope?: any): IReactionDisposer;
165 };
166 when: {
167 (name: string, predicate: () => boolean, effect: Lambda, scope?: any): IReactionDisposer;
168 (predicate: () => boolean, effect: Lambda, scope?: any): Lambda;
169 };
170 reaction: {
171 <T>(expression: (r: IReactionPublic) => T, effect: (arg: T, r: IReactionPublic) => void, opts?: IReactionOptions | undefined): IReactionDisposer;
172 <T>(expression: (r: IReactionPublic) => T, effect: (arg: T, r: IReactionPublic) => void, fireImmediately?: boolean | undefined): IReactionDisposer;
173 };
174 action: IActionFactory;
175 isAction: (thing: any) => boolean;
176 runInAction: {
177 <T>(block: () => T, scope?: any): T;
178 <T>(name: string, block: () => T, scope?: any): T;
179 };
180 expr: <T>(expr: () => T, scope?: any) => T;
181 toJS: {
182 <T>(source: T, detectCycles?: boolean | undefined): T;
183 (source: any, detectCycles?: boolean | undefined): any;
184 (source: any, detectCycles: boolean, __alreadySeen: [any, any][]): any;
185 };
186 createTransformer: <A, B>(transformer: ITransformer<A, B>, onCleanup?: ((resultObject: B | undefined, sourceObject?: A | undefined) => void) | undefined) => ITransformer<A, B>;
187 whyRun: (thing?: any, prop?: string | undefined) => string;
188 isArrayLike: (x: any) => x is any[] | IObservableArray<any>;
189 extras: {
190 allowStateChanges: <T>(allowStateChanges: boolean, func: () => T) => T;
191 deepEqual: (a: any, b: any) => any;
192 getAtom: (thing: any, property?: string | undefined) => IDepTreeNode;
193 getDebugName: (thing: any, property?: string | undefined) => string;
194 getDependencyTree: (thing: any, property?: string | undefined) => IDependencyTree;
195 getAdministration: (thing: any, property?: string | undefined) => any;
196 getGlobalState: () => any;
197 getObserverTree: (thing: any, property?: string | undefined) => IObserverTree;
198 interceptReads: {
199 <T>(value: IObservableValue<T>, handler: (value: any) => T): Lambda;
200 <T>(observableArray: IObservableArray<T>, handler: (value: any) => T): Lambda;
201 <T>(observableMap: ObservableMap<T>, handler: (value: any) => T): Lambda;
202 (object: Object, property: string, handler: (value: any) => any): Lambda;
203 };
204 isComputingDerivation: () => boolean;
205 isSpyEnabled: () => boolean;
206 onReactionError: (handler: (error: any, derivation: IDerivation) => void) => () => void;
207 reserveArrayBuffer: (max: number) => void;
208 resetGlobalState: () => void;
209 isolateGlobalState: () => void;
210 shareGlobalState: () => void;
211 spyReport: (event: any) => void;
212 spyReportEnd: (change?: any) => void;
213 spyReportStart: (event: any) => void;
214 setReactionScheduler: (fn: (f: () => void) => void) => void;
215 };
216};
217export default everything;