mobx 3.1.17 → 3.3.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.
package/lib/mobx.js.flow CHANGED
@@ -1,550 +1,488 @@
1
- declare module 'mobx' {
2
- declare type Extras = {
3
- allowStateChanges: <T>(allowStateChanges: boolean, func: () => T) => T,
4
- getAtom: (thing: any, property?: string) => IDepTreeNode,
5
- getDebugName: (thing: any, property?: string) => string,
6
- getDependencyTree: (thing: any, property?: string) => IDependencyTree,
7
- getGlobalState: () => any,
8
- getObserverTree: (thing: any, property?: string) => IObserverTree,
9
- isComputingDerivation: () => boolean,
10
- isSpyEnabled: () => boolean,
11
- resetGlobalState: () => void,
12
- shareGlobalState: () => void,
13
- spyReport: (event: any) => boolean,
14
- spyReportEnd: (change?: any) => void,
15
- spyReportStart: (event: any) => void,
16
- setReactionScheduler: (fn: (f: () => void) => void) => void,
17
- onReactionError: (error: Error) => void,
18
- };
19
-
20
- declare var extras: Extras;
21
-
22
- declare type IObservableMapInitialValues<V> =
23
- | IMapEntries<V>
24
- | IKeyValueMap<V>
25
- | IMap<string, V>;
26
-
27
- declare interface IReactionOptions {
28
- context?: any,
29
- fireImmediately?: boolean,
30
- delay?: number,
31
- compareStructural?: boolean,
32
- name?: string,
33
- }
34
-
35
- declare interface IInterceptable<T> {
36
- interceptors: IInterceptor<T>[] | any,
37
- intercept(handler: IInterceptor<T>): Lambda,
38
- }
39
-
40
- declare type _ = {
41
- getAdministration: (thing: any, property?: string) => any,
42
- resetGlobalState: () => void,
43
- };
44
-
45
- declare type ITransformer<A, B> = (object: A) => B;
46
-
47
- declare type IInterceptor<T> = (change: T) => T;
48
-
49
- declare type IMapEntry<V> = [string, V];
50
-
51
- declare type IMapEntries<V> = IMapEntry<V>[];
52
-
53
- declare interface IMap<K, V> {
54
- clear(): void,
55
- delete(key: K): boolean,
56
- forEach(
57
- callbackfn: (value: V, index: K, map: IMap<K, V>) => void,
58
- thisArg?: any,
59
- ): void,
60
- get(key: K): V | any,
61
- has(key: K): boolean,
62
- set(key: K, value?: V): any,
63
- size: number,
64
- }
65
-
66
- declare type isObservableMap = (x: any) => boolean;
67
-
68
- declare type ISimpleEventListener = {
69
- (): void,
70
- };
71
-
72
- declare interface IComputedValueOptions<T> {
73
- compareStructural?: boolean,
74
- name?: string,
75
- setter?: (value: T) => void,
76
- context?: any,
77
- }
78
-
79
- declare type IDerivationState =
80
- | 'NOT_TRACKING'
81
- | 'UP_TO_DATE'
82
- | 'POSSIBLY_STALE'
83
- | 'STALE';
84
- declare type PropertyDescriptor = any;
85
-
86
- declare interface IComputed {
87
- <T>(func: () => T, setter?: (value: T) => void): IComputedValue<T>,
88
- <T>(func: () => T, options: IComputedValueOptions<T>): IComputedValue<T>,
89
- (target: Object, key: string, baseDescriptor?: PropertyDescriptor): void,
90
- struct(
91
- target: Object,
92
- key: string,
93
- baseDescriptor?: PropertyDescriptor,
94
- ): void,
95
- }
96
-
97
- declare interface IDependencyTree {
98
- name: string,
99
- dependencies?: IDependencyTree[],
100
- }
101
-
102
- declare interface IObserverTree {
103
- name: string,
104
- observers?: IObserverTree[],
105
- }
106
-
107
- declare interface IAtom {}
108
-
109
- declare interface IComputedValue<T> {
110
- get(): T,
111
- set(value: T): void,
112
- observe(
113
- listener: (newValue: T, oldValue: T) => void,
114
- fireImmediately?: boolean,
115
- ): Lambda,
116
- }
117
-
118
- declare interface IObservable {
119
- diffValue: number,
120
- lastAccessedBy: number,
121
- lowestObserverState: IDerivationState,
122
- isPendingUnobservation: boolean,
123
- observers: IDerivation[],
124
- observersIndexes: {},
125
- onBecomeUnobserved(): any,
126
- }
127
-
128
- declare interface IDepTreeNode {
129
- name: string,
130
- observing?: IObservable[],
131
- }
132
-
133
- declare interface IDerivation {
134
- name: string,
135
- observing: IObservable[],
136
- newObserving: ?(IObservable[]),
137
- dependenciesState: IDerivationState,
138
- runId: number,
139
- unboundDepsCount: number,
140
- ___mapid: string,
141
- onBecomeStale(): any,
142
- recoverFromError(): any,
143
- }
144
-
145
- declare interface IReactionPublic {
146
- dispose: () => void,
147
- }
148
-
149
- declare interface IListenable {
150
- changeListeners: any,
151
- observe(
152
- handler: (change: any, oldValue?: any) => void,
153
- fireImmediately?: boolean,
154
- ): Lambda,
155
- }
156
-
157
- declare interface IObservableArray<T> extends Array<T> {
158
- spliceWithArray(index: number, deleteCount?: number, newItems?: T[]): T[],
159
- observe(
160
- listener: (changeData: IArrayChange<T> | IArraySplice<T>) => void,
161
- fireImmediately?: boolean,
162
- ): Lambda,
163
- intercept(handler: IInterceptor<IArrayWillChange<T> | IArrayWillSplice<T>>): Lambda,
164
- intercept(handler: IInterceptor<IArrayChange<T> | IArraySplice<T>>): Lambda, // TODO: remove in 4.0
165
- intercept<T>(
166
- handler: IInterceptor<IArrayChange<T> | IArraySplice<T>>,
167
- ): Lambda, // TODO: remove in 4.0
168
- clear(): T[],
169
- peek(): T[],
170
- replace(newItems: T[]): T[],
171
- find(
172
- predicate: (item: T, index: number, array: Array<T>) => boolean,
173
- thisArg?: any,
174
- fromIndex?: number,
175
- ): T | any,
176
- findIndex(
177
- predicate: (item: T, index: number, array: Array<T>) => boolean,
178
- thisArg?: any,
179
- fromIndex?: number,
180
- ): number,
181
- remove(value: T): boolean,
182
- }
183
-
184
- declare interface IArrayChange<T> {
185
- type: 'update',
186
- object: IObservableArray<T>,
187
- index: number,
188
- newValue: T,
189
- oldValue: T,
190
- }
191
-
192
- declare interface IArraySplice<T> {
193
- type: 'splice',
194
- object: IObservableArray<T>,
195
- index: number,
196
- added: T[],
197
- addedCount: number,
198
- removed: T[],
199
- removedCount: number,
200
- }
201
-
202
- declare interface IArrayWillChange<T> {
203
- type: 'update',
204
- object: IObservableArray<T>,
205
- index: number,
206
- newValue: T,
207
- }
208
-
209
- declare interface IArrayWillSplice<T> {
210
- type: 'splice',
211
- object: IObservableArray<T>,
212
- index: number,
213
- added: T[],
214
- removedCount: number,
215
- }
216
-
217
- declare interface IKeyValueMap<V> {
218
- [key: string]: V,
219
- }
220
-
221
- declare interface IMapChange<T> {
222
- object: ObservableMap<T>,
223
- type: 'update' | 'add' | 'delete',
224
- name: string,
225
- newValue?: any,
226
- oldValue?: any,
227
- }
228
-
229
- declare interface IMapWillChange<T> {
230
- object: ObservableMap<T>,
231
- type: 'update' | 'add' | 'delete',
232
- name: string,
233
- newValue?: any,
234
- }
235
-
236
- declare interface IObservableObject {}
237
-
238
- declare interface IObjectChange {
239
- name: string,
240
- object: any,
241
- type: 'update' | 'add',
242
- oldValue?: any,
243
- newValue: any,
244
- }
245
-
246
- declare interface IObjectWillChange {
247
- object: any,
248
- type: 'update' | 'add',
249
- name: string,
250
- newValue: any,
251
- }
252
-
253
- declare interface IValueWillChange<T> {
254
- object: any,
255
- type: 'update',
256
- newValue: T,
257
- }
258
-
259
- declare interface IValueDidChange<T> extends IValueWillChange<T> {
260
- oldValue: T | typeof undefined,
261
- }
262
-
263
- declare interface IObservableValue<T> {
264
- get(): T,
265
- set(value: T): void,
266
- intercept(handler: IInterceptor<IValueWillChange<T>>): Lambda,
267
- observe(
268
- listener: (change: IValueDidChange<T>) => void,
269
- fireImmediately?: boolean,
270
- ): Lambda,
271
- }
272
-
273
- declare interface IObservableFactory {
274
- (value: any, key?: string, baseDescriptor?: PropertyDescriptor): any,
275
- }
276
-
277
- declare class IObservableFactories {
278
- box<T>(value?: T, name?: string): IObservableValue<T>,
279
- shallowBox<T>(value?: T, name?: string): IObservableValue<T>,
280
- array<T>(initialValues?: T[], name?: string): IObservableArray<T>,
281
- shallowArray<T>(initialValues?: T[], name?: string): IObservableArray<T>,
282
- map<T>(
283
- initialValues?: IObservableMapInitialValues<T>,
284
- name?: string,
285
- ): ObservableMap<T>,
286
- shallowMap<T>(
287
- initialValues?: IObservableMapInitialValues<T>,
288
- name?: string,
289
- ): ObservableMap<T>,
290
- object<T>(props: T, name?: string): T & IObservableObject,
291
- shallowObject<T>(props: T, name?: string): T & IObservableObject,
292
- ref(target: Object, property?: string, descriptor?: PropertyDescriptor): any,
293
- shallow(
294
- target: Object,
295
- property?: string,
296
- descriptor?: PropertyDescriptor,
297
- ): any,
298
- deep(target: Object, property?: string, descriptor?: PropertyDescriptor): any,
299
- }
300
-
301
- declare interface Iterator<T> {
302
- next(): {
303
- done: boolean,
304
- value?: T,
305
- },
306
- }
307
-
308
- declare interface Lambda {
309
- (): void,
310
- name?: string,
311
- }
312
-
313
- declare interface IActionFactory {
314
- (a1: any, a2?: any, a3?: any, a4?: any, a6?: any): any,
315
- bound(
316
- target: Object,
317
- propertyKey: string,
318
- descriptor?: PropertyDescriptor,
319
- ): void,
320
- }
321
-
322
- declare class ObservableMap<V> {
323
- $mobx: {},
324
- name: string,
325
- interceptors: any,
326
- changeListeners: any,
327
- constructor(
328
- initialData?: IMapEntries<V> | IKeyValueMap<V>,
329
- valueModeFunc?: Function,
330
- ): this,
331
- has(key: string): boolean,
332
- set(key: string, value: V): void,
333
- delete(key: string): boolean,
334
- get(key: string): V,
335
- keys(): string[] & Iterator<string>,
336
- values(): V[] & Iterator<V>,
337
- entries(): IMapEntries<V> & Iterator<IMapEntry<V>>,
338
- forEach(
339
- callback: (value: V, key: string, object: IKeyValueMap<V>) => void,
340
- thisArg?: any,
341
- ): void,
342
- merge(other: ObservableMap<V> | IKeyValueMap<V>): ObservableMap<V>,
343
- clear(): void,
344
- replace(other: ObservableMap<V> | IKeyValueMap<V>): ObservableMap<V>,
345
- size: number,
346
- toJS(): IKeyValueMap<V>,
347
- toJs(): IKeyValueMap<V>,
348
- toJSON(): IKeyValueMap<V>,
349
- toString(): string,
350
- observe(
351
- listener: (changes: IMapChange<V>) => void,
352
- fireImmediately?: boolean,
353
- ): Lambda,
354
- intercept(handler: IInterceptor<IMapWillChange<V>>): Lambda,
355
- }
356
-
357
- declare function extendShallowObservable(target: any): any;
358
-
359
- declare function action(
360
- targetOrName: any,
361
- propertyKeyOrFuc?: any,
362
- descriptor?: PropertyDescriptor,
363
- ): any;
364
- declare function action<T>(name: string, func: T): T;
365
- declare function action<T>(func: T): T;
366
- declare function runInAction<T>(name: string, block: () => T, scope?: any): T;
367
- declare function runInAction<T>(block: () => T, scope?: any): T;
368
- declare function isAction(thing: any): boolean;
369
- declare function autorun(
370
- nameOrFunction: string | ((r: IReactionPublic) => any),
371
- viewOrScope?: any,
372
- scope?: any,
373
- ): any;
374
- declare function when(
375
- name: string,
376
- cond: () => boolean,
377
- effect: Lambda,
378
- scope?: any,
379
- ): any;
380
- declare function when(cond: () => boolean, effect: Lambda, scope?: any): any;
381
- declare function autorunAsync(
382
- func: (r: IReactionPublic) => any,
383
- delay?: number,
384
- scope?: any,
385
- ): any;
386
- declare function reaction<T>(
387
- expression: (r: IReactionPublic) => T,
388
- effect: (arg: T, r: IReactionPublic) => void,
389
- fireImmediately?: boolean,
390
- delay?: number,
391
- scope?: any,
392
- ): any;
393
-
394
- declare function computed<T>(
395
- target: any,
396
- key?: string,
397
- baseDescriptor?: PropertyDescriptor,
398
- ): any;
399
- declare function createTransformer<A, B>(
400
- transformer: ITransformer<A, B>,
401
- onCleanup?: (resultObject: ?B | any, sourceObject?: A) => void,
402
- ): ITransformer<A, B>;
403
- declare function expr<T>(expr: () => T, scope?: any): T;
404
- declare function extendObservable<A, B>(target: A, ...properties: B[]): A & B;
405
-
406
- declare function intercept(
407
- object: Object,
408
- property: string,
409
- handler: IInterceptor<any>,
410
- ): Lambda;
411
-
412
- declare function isComputed(value: any, property?: string): boolean;
413
-
414
- declare function isObservable(value: any, property?: string): boolean;
415
-
416
- declare function observable<T>(value: T): any;
417
-
418
- declare function observe<T>(
419
- value: IObservableValue<T> | IComputedValue<T>,
420
- listener: (change: IValueDidChange<T>) => void,
421
- fireImmediately?: boolean,
422
- ): Lambda;
423
- declare function observe<T>(
424
- observableArray: IObservableArray<T>,
425
- listener: (change: IArrayChange<T> | IArraySplice<T>) => void,
426
- fireImmediately?: boolean,
427
- ): Lambda;
428
- declare function observe<T>(
429
- observableMap: ObservableMap<T>,
430
- listener: (change: IMapChange<T>) => void,
431
- fireImmediately?: boolean,
432
- ): Lambda;
433
- declare function observe<T>(
434
- observableMap: ObservableMap<T>,
435
- property: string,
436
- listener: (change: IValueDidChange<T>) => void,
437
- fireImmediately?: boolean,
438
- ): Lambda;
439
- declare function observe(
440
- object: any,
441
- listener: (change: IObjectChange) => void,
442
- fireImmediately?: boolean,
443
- ): Lambda;
444
- declare function observe(
445
- object: any,
446
- property: string,
447
- listener: (change: IValueDidChange<any>) => void,
448
- fireImmediately?: boolean,
449
- ): Lambda;
450
-
451
- declare function toJS(
452
- source: any,
453
- detectCycles?: boolean,
454
- ___alreadySeen?: [any, any][],
455
- ): any;
456
- declare function toJSlegacy(
457
- source: any,
458
- detectCycles?: boolean,
459
- ___alreadySeen?: [any, any][],
460
- ): any;
461
- declare function whyRun(thing?: any, prop?: string): string;
462
- declare function useStrict(strict: boolean): any;
463
-
464
- declare function isStrictModeEnabled(): boolean;
465
- declare function untracked<T>(action: () => T): T;
466
-
467
- declare function spy(listener: (change: any) => void): Lambda;
468
-
469
- declare function transaction<T>(
470
- action: () => T,
471
- thisArg?: any,
472
- report?: boolean,
473
- ): T;
474
-
475
- declare function asReference<T>(value: T): T;
476
- declare function asStructure<T>(value: T): T;
477
- declare function asFlat<T>(value: T): T;
478
- declare function asMap<T>(
479
- data: IKeyValueMap<T>,
480
- modifierFunc?: Function,
481
- ): ObservableMap<T>;
482
- declare function isObservableArray(thing: any): boolean;
483
-
484
- declare function map<V>(
485
- initialValues?: IMapEntries<V> | IKeyValueMap<V>,
486
- valueModifier?: Function,
487
- ): ObservableMap<V>;
488
-
489
- declare function isObservableObject<T>(thing: T): boolean;
490
-
491
- declare function isArrayLike(x: any): boolean;
492
-
493
- declare class BaseAtom {
494
- name: string,
495
- isPendingUnobservation: boolean,
496
- observers: any[],
497
- observersIndexes: {},
498
- diffValue: number,
499
- lastAccessedBy: number,
500
- lowestObserverState: IDerivationState,
501
- constructor(name?: string): this,
502
- onBecomeUnobserved(): void,
503
- reportObserved(): void,
504
- reportChanged(): void,
505
- toString(): string,
506
- }
507
-
508
- declare class Atom {
509
- name: string,
510
- onBecomeObservedHandler: () => void,
511
- onBecomeUnobservedHandler: () => void,
512
- isPendingUnobservation: boolean,
513
- isBeingTracked: boolean,
514
- constructor(
515
- name?: string,
516
- onBecomeObservedHandler?: () => void,
517
- onBecomeUnobservedHandler?: () => void,
518
- ): this,
519
- reportObserved(): boolean,
520
- onBecomeUnobserved(): void,
521
- }
522
-
523
- declare class Reaction {
524
- name: string,
525
- observing: any[],
526
- newObserving: any[],
527
- dependenciesState: IDerivationState,
528
- diffValue: number,
529
- runId: number,
530
- unboundDepsCount: number,
531
- ___mapid: string,
532
- isDisposed: boolean,
533
- _isScheduled: boolean,
534
- _isTrackPending: boolean,
535
- _isRunning: boolean,
536
- constructor(name: string, onInvalidate: () => void): this,
537
- onBecomeStale(): void,
538
- schedule(): void,
539
- isScheduled(): boolean,
540
- runReaction(): void,
541
- track(fn: () => void): void,
542
- recoverFromError(): void,
543
- dispose(): void,
544
- getDisposer(): Lambda & {
545
- $mosbservable: Reaction,
546
- },
547
- toString(): string,
548
- whyRun(): string,
549
- }
1
+ declare module "mobx" {
2
+ declare type Extras = {
3
+ allowStateChanges: <T>(allowStateChanges: boolean, func: () => T) => T,
4
+ getAtom: (thing: any, property?: string) => IDepTreeNode,
5
+ getDebugName: (thing: any, property?: string) => string,
6
+ getDependencyTree: (thing: any, property?: string) => IDependencyTree,
7
+ getGlobalState: () => any,
8
+ getObserverTree: (thing: any, property?: string) => IObserverTree,
9
+ isComputingDerivation: () => boolean,
10
+ isSpyEnabled: () => boolean,
11
+ resetGlobalState: () => void,
12
+ shareGlobalState: () => void,
13
+ spyReport: (event: any) => boolean,
14
+ spyReportEnd: (change?: any) => void,
15
+ spyReportStart: (event: any) => void,
16
+ setReactionScheduler: (fn: (f: () => void) => void) => void,
17
+ onReactionError: ((error: Error) => void) => void
18
+ }
19
+
20
+ declare var extras: Extras
21
+
22
+ declare type IObservableMapInitialValues<V> = IMapEntries<V> | IKeyValueMap<V> | IMap<string, V>
23
+
24
+ declare interface IReactionOptions {
25
+ context?: any,
26
+ fireImmediately?: boolean,
27
+ delay?: number,
28
+ compareStructural?: boolean,
29
+ name?: string
30
+ }
31
+
32
+ declare interface IInterceptable<T> {
33
+ interceptors: IInterceptor<T>[] | any,
34
+ intercept(handler: IInterceptor<T>): Lambda
35
+ }
36
+
37
+ declare type _ = {
38
+ getAdministration: (thing: any, property?: string) => any,
39
+ resetGlobalState: () => void
40
+ }
41
+
42
+ declare type ITransformer<A, B> = (object: A) => B
43
+
44
+ declare type IInterceptor<T> = (change: T) => T
45
+
46
+ declare type IMapEntry<V> = [string, V]
47
+
48
+ declare type IMapEntries<V> = IMapEntry<V>[]
49
+
50
+ declare interface IMap<K, V> {
51
+ clear(): void,
52
+ delete(key: K): boolean,
53
+ forEach(callbackfn: (value: V, index: K, map: IMap<K, V>) => void, thisArg?: any): void,
54
+ get(key: K): V | any,
55
+ has(key: K): boolean,
56
+ set(key: K, value?: V): any,
57
+ size: number
58
+ }
59
+
60
+ declare type isObservableMap = (x: any) => boolean
61
+
62
+ declare type ISimpleEventListener = {
63
+ (): void
64
+ }
65
+
66
+ declare interface IComputedValueOptions<T> {
67
+ compareStructural?: boolean,
68
+ name?: string,
69
+ setter?: (value: T) => void,
70
+ context?: any
71
+ }
72
+
73
+ declare type IDerivationState = "NOT_TRACKING" | "UP_TO_DATE" | "POSSIBLY_STALE" | "STALE"
74
+ declare type PropertyDescriptor = any
75
+
76
+ declare interface IComputed {
77
+ <T>(func: () => T, setter?: (value: T) => void): IComputedValue<T>,
78
+ <T>(func: () => T, options: IComputedValueOptions<T>): IComputedValue<T>,
79
+ (target: Object, key: string, baseDescriptor?: PropertyDescriptor): void,
80
+ struct(target: Object, key: string, baseDescriptor?: PropertyDescriptor): void
81
+ }
82
+
83
+ declare interface IDependencyTree {
84
+ name: string,
85
+ dependencies?: IDependencyTree[]
86
+ }
87
+
88
+ declare interface IObserverTree {
89
+ name: string,
90
+ observers?: IObserverTree[]
91
+ }
92
+
93
+ declare interface IAtom {}
94
+
95
+ declare interface IComputedValue<T> {
96
+ get(): T,
97
+ set(value: T): void,
98
+ observe(listener: (newValue: T, oldValue: T) => void, fireImmediately?: boolean): Lambda
99
+ }
100
+
101
+ declare interface IObservable {
102
+ diffValue: number,
103
+ lastAccessedBy: number,
104
+ lowestObserverState: IDerivationState,
105
+ isPendingUnobservation: boolean,
106
+ observers: IDerivation[],
107
+ observersIndexes: {},
108
+ onBecomeUnobserved(): any
109
+ }
110
+
111
+ declare interface IDepTreeNode {
112
+ name: string,
113
+ observing?: IObservable[]
114
+ }
115
+
116
+ declare interface IDerivation {
117
+ name: string,
118
+ observing: IObservable[],
119
+ newObserving: ?(IObservable[]),
120
+ dependenciesState: IDerivationState,
121
+ runId: number,
122
+ unboundDepsCount: number,
123
+ ___mapid: string,
124
+ onBecomeStale(): any,
125
+ recoverFromError(): any
126
+ }
127
+
128
+ declare interface IReactionPublic {
129
+ dispose: () => void
130
+ }
131
+
132
+ declare interface IListenable {
133
+ changeListeners: any,
134
+ observe(handler: (change: any, oldValue?: any) => void, fireImmediately?: boolean): Lambda
135
+ }
136
+
137
+ declare interface IObservableArray<T> extends Array<T> {
138
+ spliceWithArray(index: number, deleteCount?: number, newItems?: T[]): T[],
139
+ observe(
140
+ listener: (changeData: IArrayChange<T> | IArraySplice<T>) => void,
141
+ fireImmediately?: boolean
142
+ ): Lambda,
143
+ intercept(handler: IInterceptor<IArrayWillChange<T> | IArrayWillSplice<T>>): Lambda,
144
+ intercept(handler: IInterceptor<IArrayChange<T> | IArraySplice<T>>): Lambda, // TODO: remove in 4.0
145
+ intercept<T>(handler: IInterceptor<IArrayChange<T> | IArraySplice<T>>): Lambda, // TODO: remove in 4.0
146
+ clear(): T[],
147
+ peek(): T[],
148
+ replace(newItems: T[]): T[],
149
+ find(
150
+ predicate: (item: T, index: number, array: Array<T>) => boolean,
151
+ thisArg?: any,
152
+ fromIndex?: number
153
+ ): T | any,
154
+ findIndex(
155
+ predicate: (item: T, index: number, array: Array<T>) => boolean,
156
+ thisArg?: any,
157
+ fromIndex?: number
158
+ ): number,
159
+ remove(value: T): boolean
160
+ }
161
+
162
+ declare interface IArrayChange<T> {
163
+ type: "update",
164
+ object: IObservableArray<T>,
165
+ index: number,
166
+ newValue: T,
167
+ oldValue: T
168
+ }
169
+
170
+ declare interface IArraySplice<T> {
171
+ type: "splice",
172
+ object: IObservableArray<T>,
173
+ index: number,
174
+ added: T[],
175
+ addedCount: number,
176
+ removed: T[],
177
+ removedCount: number
178
+ }
179
+
180
+ declare interface IArrayWillChange<T> {
181
+ type: "update",
182
+ object: IObservableArray<T>,
183
+ index: number,
184
+ newValue: T
185
+ }
186
+
187
+ declare interface IArrayWillSplice<T> {
188
+ type: "splice",
189
+ object: IObservableArray<T>,
190
+ index: number,
191
+ added: T[],
192
+ removedCount: number
193
+ }
194
+
195
+ declare interface IKeyValueMap<V> {
196
+ [key: string]: V
197
+ }
198
+
199
+ declare interface IMapChange<T> {
200
+ object: ObservableMap<T>,
201
+ type: "update" | "add" | "delete",
202
+ name: string,
203
+ newValue?: any,
204
+ oldValue?: any
205
+ }
206
+
207
+ declare interface IMapWillChange<T> {
208
+ object: ObservableMap<T>,
209
+ type: "update" | "add" | "delete",
210
+ name: string,
211
+ newValue?: any
212
+ }
213
+
214
+ declare interface IObservableObject {}
215
+
216
+ declare interface IObjectChange {
217
+ name: string,
218
+ object: any,
219
+ type: "update" | "add",
220
+ oldValue?: any,
221
+ newValue: any
222
+ }
223
+
224
+ declare interface IObjectWillChange {
225
+ object: any,
226
+ type: "update" | "add",
227
+ name: string,
228
+ newValue: any
229
+ }
230
+
231
+ declare interface IValueWillChange<T> {
232
+ object: any,
233
+ type: "update",
234
+ newValue: T
235
+ }
236
+
237
+ declare interface IValueDidChange<T> extends IValueWillChange<T> {
238
+ oldValue: T | typeof undefined
239
+ }
240
+
241
+ declare interface IObservableValue<T> {
242
+ get(): T,
243
+ set(value: T): void,
244
+ intercept(handler: IInterceptor<IValueWillChange<T>>): Lambda,
245
+ observe(listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean): Lambda
246
+ }
247
+
248
+ declare interface IObservableFactory {
249
+ (value: any, key?: string, baseDescriptor?: PropertyDescriptor): any
250
+ }
251
+
252
+ declare class IObservableFactories {
253
+ box<T>(value?: T, name?: string): IObservableValue<T>,
254
+ shallowBox<T>(value?: T, name?: string): IObservableValue<T>,
255
+ array<T>(initialValues?: T[], name?: string): IObservableArray<T>,
256
+ shallowArray<T>(initialValues?: T[], name?: string): IObservableArray<T>,
257
+ map<T>(initialValues?: IObservableMapInitialValues<T>, name?: string): ObservableMap<T>,
258
+ shallowMap<T>(
259
+ initialValues?: IObservableMapInitialValues<T>,
260
+ name?: string
261
+ ): ObservableMap<T>,
262
+ object<T>(props: T, name?: string): T & IObservableObject,
263
+ shallowObject<T>(props: T, name?: string): T & IObservableObject,
264
+ ref(target: Object, property?: string, descriptor?: PropertyDescriptor): any,
265
+ shallow(target: Object, property?: string, descriptor?: PropertyDescriptor): any,
266
+ deep(target: Object, property?: string, descriptor?: PropertyDescriptor): any
267
+ }
268
+
269
+ declare interface Iterator<T> {
270
+ next(): {
271
+ done: boolean,
272
+ value?: T
273
+ }
274
+ }
275
+
276
+ declare interface Lambda {
277
+ (): void,
278
+ name?: string
279
+ }
280
+
281
+ declare interface IActionFactory {
282
+ (a1: any, a2?: any, a3?: any, a4?: any, a6?: any): any,
283
+ bound(target: Object, propertyKey: string, descriptor?: PropertyDescriptor): void
284
+ }
285
+
286
+ declare class ObservableMap<V> {
287
+ $mobx: {},
288
+ name: string,
289
+ interceptors: any,
290
+ changeListeners: any,
291
+ constructor(initialData?: IMapEntries<V> | IKeyValueMap<V>, valueModeFunc?: Function): this,
292
+ has(key: string): boolean,
293
+ set(key: string, value: V): void,
294
+ delete(key: string): boolean,
295
+ get(key: string): V,
296
+ keys(): string[] & Iterator<string>,
297
+ values(): V[] & Iterator<V>,
298
+ entries(): IMapEntries<V> & Iterator<IMapEntry<V>>,
299
+ forEach(
300
+ callback: (value: V, key: string, object: IKeyValueMap<V>) => void,
301
+ thisArg?: any
302
+ ): void,
303
+ merge(other: ObservableMap<V> | IKeyValueMap<V>): ObservableMap<V>,
304
+ clear(): void,
305
+ replace(other: ObservableMap<V> | IKeyValueMap<V>): ObservableMap<V>,
306
+ size: number,
307
+ toJS(): IKeyValueMap<V>,
308
+ toJs(): IKeyValueMap<V>,
309
+ toJSON(): IKeyValueMap<V>,
310
+ toString(): string,
311
+ observe(listener: (changes: IMapChange<V>) => void, fireImmediately?: boolean): Lambda,
312
+ intercept(handler: IInterceptor<IMapWillChange<V>>): Lambda
313
+ }
314
+
315
+ declare function extendShallowObservable(target: any): any
316
+
317
+ declare function action(
318
+ targetOrName: any,
319
+ propertyKeyOrFuc?: any,
320
+ descriptor?: PropertyDescriptor
321
+ ): any
322
+ declare function action<T>(name: string, func: T): T
323
+ declare function action<T>(func: T): T
324
+ declare function runInAction<T>(name: string, block: () => T, scope?: any): T
325
+ declare function runInAction<T>(block: () => T, scope?: any): T
326
+ declare function isAction(thing: any): boolean
327
+ declare function autorun(
328
+ nameOrFunction: string | ((r: IReactionPublic) => any),
329
+ viewOrScope?: any,
330
+ scope?: any
331
+ ): any
332
+ declare function when(name: string, cond: () => boolean, effect: Lambda, scope?: any): any
333
+ declare function when(cond: () => boolean, effect: Lambda, scope?: any): any
334
+ declare function autorunAsync(
335
+ func: (r: IReactionPublic) => any,
336
+ delay?: number,
337
+ scope?: any
338
+ ): any
339
+ declare function reaction<T>(
340
+ expression: (r: IReactionPublic) => T,
341
+ effect: (arg: T, r: IReactionPublic) => void,
342
+ fireImmediately?: boolean,
343
+ delay?: number,
344
+ scope?: any
345
+ ): any
346
+
347
+ declare function computed<T>(
348
+ target: any,
349
+ key?: string,
350
+ baseDescriptor?: PropertyDescriptor
351
+ ): any
352
+ declare function createTransformer<A, B>(
353
+ transformer: ITransformer<A, B>,
354
+ onCleanup?: (resultObject: ?B | any, sourceObject?: A) => void
355
+ ): ITransformer<A, B>
356
+ declare function expr<T>(expr: () => T, scope?: any): T
357
+ declare function extendObservable<A, B>(target: A, ...properties: B[]): A & B
358
+
359
+ declare function intercept(object: Object, property: string, handler: IInterceptor<any>): Lambda
360
+
361
+ declare function isComputed(value: any, property?: string): boolean
362
+
363
+ declare function isObservable(value: any, property?: string): boolean
364
+
365
+ declare function observable<T>(value: T): any
366
+
367
+ declare function observe<T>(
368
+ value: IObservableValue<T> | IComputedValue<T>,
369
+ listener: (change: IValueDidChange<T>) => void,
370
+ fireImmediately?: boolean
371
+ ): Lambda
372
+ declare function observe<T>(
373
+ observableArray: IObservableArray<T>,
374
+ listener: (change: IArrayChange<T> | IArraySplice<T>) => void,
375
+ fireImmediately?: boolean
376
+ ): Lambda
377
+ declare function observe<T>(
378
+ observableMap: ObservableMap<T>,
379
+ listener: (change: IMapChange<T>) => void,
380
+ fireImmediately?: boolean
381
+ ): Lambda
382
+ declare function observe<T>(
383
+ observableMap: ObservableMap<T>,
384
+ property: string,
385
+ listener: (change: IValueDidChange<T>) => void,
386
+ fireImmediately?: boolean
387
+ ): Lambda
388
+ declare function observe(
389
+ object: any,
390
+ listener: (change: IObjectChange) => void,
391
+ fireImmediately?: boolean
392
+ ): Lambda
393
+ declare function observe(
394
+ object: any,
395
+ property: string,
396
+ listener: (change: IValueDidChange<any>) => void,
397
+ fireImmediately?: boolean
398
+ ): Lambda
399
+
400
+ declare function toJS(source: any, detectCycles?: boolean, ___alreadySeen?: [any, any][]): any
401
+ declare function toJSlegacy(
402
+ source: any,
403
+ detectCycles?: boolean,
404
+ ___alreadySeen?: [any, any][]
405
+ ): any
406
+ declare function whyRun(thing?: any, prop?: string): string
407
+ declare function useStrict(strict: boolean): void
408
+
409
+ declare function isStrictModeEnabled(): boolean
410
+ declare function untracked<T>(action: () => T): T
411
+
412
+ declare function spy(listener: (change: any) => void): Lambda
413
+
414
+ declare function transaction<T>(action: () => T, thisArg?: any, report?: boolean): T
415
+
416
+ declare function asReference<T>(value: T): T
417
+ declare function asStructure<T>(value: T): T
418
+ declare function asFlat<T>(value: T): T
419
+ declare function asMap<T>(data: IKeyValueMap<T>, modifierFunc?: Function): ObservableMap<T>
420
+ declare function isObservableArray(thing: any): boolean
421
+
422
+ declare function map<V>(
423
+ initialValues?: IMapEntries<V> | IKeyValueMap<V>,
424
+ valueModifier?: Function
425
+ ): ObservableMap<V>
426
+
427
+ declare function isObservableObject<T>(thing: T): boolean
428
+
429
+ declare function isArrayLike(x: any): boolean
430
+
431
+ declare class BaseAtom {
432
+ name: string,
433
+ isPendingUnobservation: boolean,
434
+ observers: any[],
435
+ observersIndexes: {},
436
+ diffValue: number,
437
+ lastAccessedBy: number,
438
+ lowestObserverState: IDerivationState,
439
+ constructor(name?: string): this,
440
+ onBecomeUnobserved(): void,
441
+ reportObserved(): void,
442
+ reportChanged(): void,
443
+ toString(): string
444
+ }
445
+
446
+ declare class Atom {
447
+ name: string,
448
+ onBecomeObservedHandler: () => void,
449
+ onBecomeUnobservedHandler: () => void,
450
+ isPendingUnobservation: boolean,
451
+ isBeingTracked: boolean,
452
+ constructor(
453
+ name?: string,
454
+ onBecomeObservedHandler?: () => void,
455
+ onBecomeUnobservedHandler?: () => void
456
+ ): this,
457
+ reportObserved(): boolean,
458
+ onBecomeUnobserved(): void
459
+ }
460
+
461
+ declare class Reaction {
462
+ name: string,
463
+ observing: any[],
464
+ newObserving: any[],
465
+ dependenciesState: IDerivationState,
466
+ diffValue: number,
467
+ runId: number,
468
+ unboundDepsCount: number,
469
+ ___mapid: string,
470
+ isDisposed: boolean,
471
+ _isScheduled: boolean,
472
+ _isTrackPending: boolean,
473
+ _isRunning: boolean,
474
+ constructor(name: string, onInvalidate: () => void): this,
475
+ onBecomeStale(): void,
476
+ schedule(): void,
477
+ isScheduled(): boolean,
478
+ runReaction(): void,
479
+ track(fn: () => void): void,
480
+ recoverFromError(): void,
481
+ dispose(): void,
482
+ getDisposer(): Lambda & {
483
+ $mosbservable: Reaction
484
+ },
485
+ toString(): string,
486
+ whyRun(): string
487
+ }
550
488
  }