mobx 3.2.2 → 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/CHANGELOG.md +12 -0
- package/README.md +2 -1
- package/lib/api/expr.d.ts +13 -13
- package/lib/api/intercept-read.d.ts +4 -4
- package/lib/api/intercept.d.ts +1 -1
- package/lib/api/isobservable.d.ts +4 -4
- package/lib/api/tojs.d.ts +2 -2
- package/lib/core/computedvalue.d.ts +3 -1
- package/lib/mobx.d.ts +1 -1
- package/lib/mobx.js +324 -211
- package/lib/mobx.js.flow +487 -549
- package/lib/mobx.min.js +2 -2
- package/lib/mobx.min.js.map +1 -1
- package/lib/mobx.module.js +324 -211
- package/lib/mobx.umd.js +324 -211
- package/lib/mobx.umd.min.js +2 -2
- package/lib/mobx.umd.min.js.map +1 -1
- package/lib/types/observableobject.d.ts +4 -4
- package/package.json +15 -3
package/lib/mobx.js.flow
CHANGED
|
@@ -1,550 +1,488 @@
|
|
|
1
|
-
declare module
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
name: string,
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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
|
}
|