mobx 3.4.1 → 3.6.2

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 CHANGED
@@ -1,6 +1,28 @@
1
+
2
+ # 3.6.2
3
+
4
+ * Fixed accidental dependency on the `node` typings. Fixes [#1387](https://github.com/mobxjs/mobx/issues/1387) / [#1362](https://github.com/mobxjs/mobx/issues/1387)
5
+
6
+ # 3.6.1
7
+
8
+ * Fixed [#1358](https://github.com/mobxjs/mobx/pull/1359): Deep comparison failing on IE11. By [le0nik](https://github.com/le0nik) through [#1359](https://github.com/mobxjs/mobx/pull/1359)
9
+
10
+ # 3.6.0
11
+
12
+ * Fixed [#1118](https://github.com/mobxjs/mobx/issues/1118), the deepEquals operator build into mobx gave wrong results for non-primitive objects. This affected for example `computed.struct`, or the `compareStructural` of `reaction`
13
+
14
+ # 3.5.0/1
15
+
16
+ * Introduced `trace` for easier debugging of reactions / computed values. See the [docs](https://mobx.js.org/best/trace.html) for details.
17
+ * Improved typings of `observableArray.find`, see [#1324](https://github.com/mobxjs/mobx/pull/1324) for details.
18
+
19
+ # 3.4.1
20
+
21
+ * Republished 3.4.0, because the package update doesn't seem to distibute consistently through yarn / npm
22
+
1
23
  # 3.4.0
2
24
 
3
- * Improve Flow support support by exposing typings regularly. Flow will automatically include them now. In your `.flowconfig` will have to remove the import in the `[libs]` section (as it's done [here](https://github.com/mobxjs/mobx/pull/1254#issuecomment-348926416)). Fixes [#1232](https://github.com/mobxjs/mobx/issues/1232).
25
+ * Improve Flow support by exposing typings regularly. Flow will automatically include them now. In your `.flowconfig` will have to remove the import in the `[libs]` section (as it's done [here](https://github.com/mobxjs/mobx/pull/1254#issuecomment-348926416)). Fixes [#1232](https://github.com/mobxjs/mobx/issues/1232).
4
26
 
5
27
  # 3.3.3
6
28
 
package/README.md CHANGED
@@ -8,12 +8,15 @@ _Simple, scalable state management_
8
8
  [![Coverage Status](https://coveralls.io/repos/mobxjs/mobx/badge.svg?branch=master&service=github)](https://coveralls.io/github/mobxjs/mobx?branch=master)
9
9
  [![Join the chat at https://gitter.im/mobxjs/mobx](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mobxjs/mobx?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
10
10
  [![Discuss MobX on Hashnode](https://hashnode.github.io/badges/mobx.svg)](https://hashnode.com/n/mobx)
11
- [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://mobxjs.github.io/mobx/donate.html)
12
11
  [![OpenCollective](https://opencollective.com/mobx/backers/badge.svg)](#backers)
13
12
  [![OpenCollective](https://opencollective.com/mobx/sponsors/badge.svg)](#sponsors)
14
- [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
13
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
14
+
15
+ MobX is proudly sponsored by Mendix, Coinbase, Facebook Open Source and many [individual sponsors](#backers)
16
+
17
+ <img src="docs/mendix-logo.png" align="center" width="100" title="Mendix" alt="Mendix" /> <img src="docs/coinbase.jpeg" align="center" width="100" title="Coinbase" alt="Coinbase" /> <img src="docs/fbos.jpeg" align="center" width="100" title="Facebook Open Source" alt="Facebook Open Source" />
15
18
 
16
- ![npm install mobx](https://nodei.co/npm/mobx.png?downloadRank=true&downloads=true)
19
+ # Installation
17
20
 
18
21
  * Installation: `npm install mobx --save`. React bindings: `npm install mobx-react --save`. To enable ESNext decorators (optional), see below.
19
22
  * CDN:
@@ -56,7 +59,7 @@ Both React and MobX provide very optimal and unique solutions to common problems
56
59
 
57
60
  ## Core concepts
58
61
 
59
- MobX has only a few core concepts. The following snippets can be tried online using [JSFiddle](https://jsfiddle.net/mweststrate/f0dptdau/2/) (or [without ES6 and JSX](https://jsfiddle.net/rubyred/55oc981v/)).
62
+ MobX has only a few core concepts. The following snippets can be tried online using [codesandbox example](https://codesandbox.io/s/v3v0my2370).
60
63
 
61
64
  ### Observable state
62
65
 
@@ -256,13 +259,6 @@ The result of this is that you often need to learn less new concepts when using
256
259
  ---
257
260
 
258
261
 
259
-
260
- <center>
261
- <img src="https://www.mendix.com/styleguide/img/logo-mendix.png" align="center" width="200"/>
262
-
263
- __MobX is proudly used in mission critical systems at [Mendix](https://www.mendix.com)__
264
- </center>
265
-
266
262
  ## Credits
267
263
 
268
264
  MobX is inspired by reactive programming principles as found in spreadsheets. It is inspired by MVVM frameworks like in MeteorJS tracker, knockout and Vue.js. But MobX brings Transparent Functional Reactive Programming to the next level and provides a stand alone implementation. It implements TFRP in a glitch-free, synchronous, predictable and efficient manner.
@@ -300,7 +296,13 @@ And finally kudos for all the people that believed in, tried, validated and even
300
296
  * Use `npm test` to run the basic test suite, `npm run coverage` for the test suite with coverage and `npm run perf` for the performance tests.
301
297
 
302
298
  ## Flow support
303
- MobX ships with flow typings. Flow will automatically include them. Though you cannot ignore `node_modules` in your `.flowconfig` and a you **cannot** import it explicitly in the `[libs]` section.
299
+ MobX ships with [flow typings](flow-typed/mobx.js). Flow will automatically include them when you import mobx modules. Although you **do not** need to import the types explicitly, you can still do it like this: `import type { ... } from 'mobx'`.
300
+
301
+ To use the [flow typings](flow-typed/mobx.js) shipped with MobX:
302
+
303
+ * In `.flowconfig`, you **cannot** ignore `node_modules`.
304
+ * In `.flowconfig`, you **cannot** import it explicitly in the `[libs]` section.
305
+ * You **do not** need to install library definition using [flow-typed](https://github.com/flowtype/flow-typed).
304
306
 
305
307
  ## Bower support
306
308
 
@@ -309,15 +311,10 @@ Bower support is available through the infamous unpkg.com:
309
311
 
310
312
  Then use `lib/mobx.umd.js` or `lib/mobx.umd.min.js`
311
313
 
312
- ## MobX was formerly known as Mobservable.
313
-
314
- See the [changelog](https://github.com/mobxjs/mobx/blob/master/CHANGELOG.md#200) for all the details about `mobservable` to `mobx`.
315
-
316
314
  ## Donating
317
315
 
318
- Was MobX key in making your project a success? Share the victory by using the [donate button](https://mobxjs.github.io/mobx/donate.html)!
319
- MobX is developed largely in free time, so any ROI is appreciated :-).
320
- If you leave a name you will be added to the [sponsors](https://github.com/mobxjs/mobx/blob/master/sponsors.md) list :).
316
+ Was MobX key in making your project a success?
317
+ Join our [open collective](https://opencollective.com/mobx#) or use the [donate button](https://mobxjs.github.io/mobx/donate.html)!
321
318
 
322
319
  ### Backers
323
320
  Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/mobx#backer)]
@@ -352,6 +349,40 @@ Support us with a monthly donation and help us continue our activities. [[Become
352
349
  <a href="https://opencollective.com/mobx/backer/27/website" target="_blank"><img src="https://opencollective.com/mobx/backer/27/avatar.svg"></a>
353
350
  <a href="https://opencollective.com/mobx/backer/28/website" target="_blank"><img src="https://opencollective.com/mobx/backer/28/avatar.svg"></a>
354
351
  <a href="https://opencollective.com/mobx/backer/29/website" target="_blank"><img src="https://opencollective.com/mobx/backer/29/avatar.svg"></a>
352
+ <a href="https://opencollective.com/mobx/backer/30/website" target="_blank"><img src="https://opencollective.com/mobx/backer/30/avatar.svg"></a>
353
+ <a href="https://opencollective.com/mobx/backer/31/website" target="_blank"><img src="https://opencollective.com/mobx/backer/31/avatar.svg"></a>
354
+ <a href="https://opencollective.com/mobx/backer/32/website" target="_blank"><img src="https://opencollective.com/mobx/backer/32/avatar.svg"></a>
355
+ <a href="https://opencollective.com/mobx/backer/33/website" target="_blank"><img src="https://opencollective.com/mobx/backer/33/avatar.svg"></a>
356
+ <a href="https://opencollective.com/mobx/backer/34/website" target="_blank"><img src="https://opencollective.com/mobx/backer/34/avatar.svg"></a>
357
+ <a href="https://opencollective.com/mobx/backer/35/website" target="_blank"><img src="https://opencollective.com/mobx/backer/35/avatar.svg"></a>
358
+ <a href="https://opencollective.com/mobx/backer/36/website" target="_blank"><img src="https://opencollective.com/mobx/backer/36/avatar.svg"></a>
359
+ <a href="https://opencollective.com/mobx/backer/37/website" target="_blank"><img src="https://opencollective.com/mobx/backer/37/avatar.svg"></a>
360
+ <a href="https://opencollective.com/mobx/backer/38/website" target="_blank"><img src="https://opencollective.com/mobx/backer/38/avatar.svg"></a>
361
+ <a href="https://opencollective.com/mobx/backer/39/website" target="_blank"><img src="https://opencollective.com/mobx/backer/39/avatar.svg"></a>
362
+ <a href="https://opencollective.com/mobx/backer/40/website" target="_blank"><img src="https://opencollective.com/mobx/backer/40/avatar.svg"></a>
363
+ <a href="https://opencollective.com/mobx/backer/41/website" target="_blank"><img src="https://opencollective.com/mobx/backer/41/avatar.svg"></a>
364
+ <a href="https://opencollective.com/mobx/backer/42/website" target="_blank"><img src="https://opencollective.com/mobx/backer/42/avatar.svg"></a>
365
+ <a href="https://opencollective.com/mobx/backer/43/website" target="_blank"><img src="https://opencollective.com/mobx/backer/43/avatar.svg"></a>
366
+ <a href="https://opencollective.com/mobx/backer/44/website" target="_blank"><img src="https://opencollective.com/mobx/backer/44/avatar.svg"></a>
367
+ <a href="https://opencollective.com/mobx/backer/45/website" target="_blank"><img src="https://opencollective.com/mobx/backer/45/avatar.svg"></a>
368
+ <a href="https://opencollective.com/mobx/backer/46/website" target="_blank"><img src="https://opencollective.com/mobx/backer/46/avatar.svg"></a>
369
+ <a href="https://opencollective.com/mobx/backer/47/website" target="_blank"><img src="https://opencollective.com/mobx/backer/47/avatar.svg"></a>
370
+ <a href="https://opencollective.com/mobx/backer/48/website" target="_blank"><img src="https://opencollective.com/mobx/backer/48/avatar.svg"></a>
371
+ <a href="https://opencollective.com/mobx/backer/49/website" target="_blank"><img src="https://opencollective.com/mobx/backer/49/avatar.svg"></a>
372
+ <a href="https://opencollective.com/mobx/backer/50/website" target="_blank"><img src="https://opencollective.com/mobx/backer/50/avatar.svg"></a>
373
+ <a href="https://opencollective.com/mobx/backer/51/website" target="_blank"><img src="https://opencollective.com/mobx/backer/51/avatar.svg"></a>
374
+ <a href="https://opencollective.com/mobx/backer/52/website" target="_blank"><img src="https://opencollective.com/mobx/backer/52/avatar.svg"></a>
375
+ <a href="https://opencollective.com/mobx/backer/53/website" target="_blank"><img src="https://opencollective.com/mobx/backer/53/avatar.svg"></a>
376
+ <a href="https://opencollective.com/mobx/backer/54/website" target="_blank"><img src="https://opencollective.com/mobx/backer/54/avatar.svg"></a>
377
+ <a href="https://opencollective.com/mobx/backer/55/website" target="_blank"><img src="https://opencollective.com/mobx/backer/55/avatar.svg"></a>
378
+ <a href="https://opencollective.com/mobx/backer/56/website" target="_blank"><img src="https://opencollective.com/mobx/backer/56/avatar.svg"></a>
379
+ <a href="https://opencollective.com/mobx/backer/57/website" target="_blank"><img src="https://opencollective.com/mobx/backer/57/avatar.svg"></a>
380
+ <a href="https://opencollective.com/mobx/backer/58/website" target="_blank"><img src="https://opencollective.com/mobx/backer/58/avatar.svg"></a>
381
+ <a href="https://opencollective.com/mobx/backer/59/website" target="_blank"><img src="https://opencollective.com/mobx/backer/59/avatar.svg"></a>
382
+
383
+ One time donations through paypal are welcome as well and are recorded in the [sponsors](sponsors.md) list.
384
+
385
+ [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://mobxjs.github.io/mobx/donate.html)
355
386
 
356
387
  ### Sponsors
357
388
 
@@ -387,3 +418,33 @@ Become a sponsor and get your logo on our README on Github with a link to your s
387
418
  <a href="https://opencollective.com/mobx/sponsor/27/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/27/avatar.svg"></a>
388
419
  <a href="https://opencollective.com/mobx/sponsor/28/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/28/avatar.svg"></a>
389
420
  <a href="https://opencollective.com/mobx/sponsor/29/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/29/avatar.svg"></a>
421
+ <a href="https://opencollective.com/mobx/sponsor/30/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/30/avatar.svg"></a>
422
+ <a href="https://opencollective.com/mobx/sponsor/31/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/31/avatar.svg"></a>
423
+ <a href="https://opencollective.com/mobx/sponsor/32/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/32/avatar.svg"></a>
424
+ <a href="https://opencollective.com/mobx/sponsor/33/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/33/avatar.svg"></a>
425
+ <a href="https://opencollective.com/mobx/sponsor/34/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/34/avatar.svg"></a>
426
+ <a href="https://opencollective.com/mobx/sponsor/35/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/35/avatar.svg"></a>
427
+ <a href="https://opencollective.com/mobx/sponsor/36/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/36/avatar.svg"></a>
428
+ <a href="https://opencollective.com/mobx/sponsor/37/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/37/avatar.svg"></a>
429
+ <a href="https://opencollective.com/mobx/sponsor/38/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/38/avatar.svg"></a>
430
+ <a href="https://opencollective.com/mobx/sponsor/39/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/39/avatar.svg"></a>
431
+ <a href="https://opencollective.com/mobx/sponsor/40/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/40/avatar.svg"></a>
432
+ <a href="https://opencollective.com/mobx/sponsor/41/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/41/avatar.svg"></a>
433
+ <a href="https://opencollective.com/mobx/sponsor/42/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/42/avatar.svg"></a>
434
+ <a href="https://opencollective.com/mobx/sponsor/43/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/43/avatar.svg"></a>
435
+ <a href="https://opencollective.com/mobx/sponsor/44/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/44/avatar.svg"></a>
436
+ <a href="https://opencollective.com/mobx/sponsor/45/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/45/avatar.svg"></a>
437
+ <a href="https://opencollective.com/mobx/sponsor/46/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/46/avatar.svg"></a>
438
+ <a href="https://opencollective.com/mobx/sponsor/47/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/47/avatar.svg"></a>
439
+ <a href="https://opencollective.com/mobx/sponsor/48/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/48/avatar.svg"></a>
440
+ <a href="https://opencollective.com/mobx/sponsor/49/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/49/avatar.svg"></a>
441
+ <a href="https://opencollective.com/mobx/sponsor/50/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/50/avatar.svg"></a>
442
+ <a href="https://opencollective.com/mobx/sponsor/51/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/51/avatar.svg"></a>
443
+ <a href="https://opencollective.com/mobx/sponsor/52/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/52/avatar.svg"></a>
444
+ <a href="https://opencollective.com/mobx/sponsor/53/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/53/avatar.svg"></a>
445
+ <a href="https://opencollective.com/mobx/sponsor/54/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/54/avatar.svg"></a>
446
+ <a href="https://opencollective.com/mobx/sponsor/55/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/55/avatar.svg"></a>
447
+ <a href="https://opencollective.com/mobx/sponsor/56/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/56/avatar.svg"></a>
448
+ <a href="https://opencollective.com/mobx/sponsor/57/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/57/avatar.svg"></a>
449
+ <a href="https://opencollective.com/mobx/sponsor/58/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/58/avatar.svg"></a>
450
+ <a href="https://opencollective.com/mobx/sponsor/59/website" target="_blank"><img src="https://opencollective.com/mobx/sponsor/59/avatar.svg"></a>
@@ -36,7 +36,7 @@ export declare function when(name: string, predicate: () => boolean, effect: Lam
36
36
  * @param scope (optional)
37
37
  * @returns disposer function to prematurely end the observer.
38
38
  */
39
- export declare function when(predicate: () => boolean, effect: Lambda, scope?: any): Lambda;
39
+ export declare function when(predicate: () => boolean, effect: Lambda, scope?: any): IReactionDisposer;
40
40
  export declare function autorunAsync(name: string, func: (r: IReactionPublic) => any, delay?: number, scope?: any): IReactionDisposer;
41
41
  export declare function autorunAsync(func: (r: IReactionPublic) => any, delay?: number, scope?: any): IReactionDisposer;
42
42
  export interface IReactionOptions {
@@ -1 +1,4 @@
1
1
  export declare function whyRun(thing?: any, prop?: string): string;
2
+ export declare function trace(thing?: any, prop?: string, enterBreakPoint?: boolean): void;
3
+ export declare function trace(thing?: any, enterBreakPoint?: boolean): void;
4
+ export declare function trace(enterBreakPoint?: boolean): void;
@@ -1,5 +1,5 @@
1
1
  import { IObservable } from "./observable";
2
- import { IDerivation, IDerivationState, CaughtException } from "./derivation";
2
+ import { IDerivation, IDerivationState, CaughtException, TraceMode } from "./derivation";
3
3
  import { Lambda } from "../utils/utils";
4
4
  import { IEqualsComparer } from "../types/comparer";
5
5
  import { IValueDidChange } from "../types/observablevalue";
@@ -32,7 +32,7 @@ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>,
32
32
  scope: Object | undefined;
33
33
  private equals;
34
34
  dependenciesState: IDerivationState;
35
- observing: never[];
35
+ observing: IObservable[];
36
36
  newObserving: null;
37
37
  isPendingUnobservation: boolean;
38
38
  observers: never[];
@@ -48,6 +48,7 @@ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>,
48
48
  isComputing: boolean;
49
49
  isRunningSetter: boolean;
50
50
  setter: (value: T) => void;
51
+ isTracing: TraceMode;
51
52
  /**
52
53
  * Create a new computed value based on a function expression.
53
54
  *
@@ -71,11 +72,11 @@ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>,
71
72
  peek(): T;
72
73
  set(value: T): void;
73
74
  private trackAndCompute();
74
- computeValue(track: boolean): CaughtException | T;
75
+ computeValue(track: boolean): T | CaughtException;
75
76
  observe(listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean): Lambda;
76
77
  toJSON(): T;
77
78
  toString(): string;
78
79
  valueOf(): T;
79
80
  whyRun(): string;
80
81
  }
81
- export declare const isComputedValue: (x: any) => x is ComputedValue<any>;
82
+ export declare const isComputedValue: (x: any) => x is ComputedValue<{}>;
@@ -6,6 +6,11 @@ export declare enum IDerivationState {
6
6
  POSSIBLY_STALE = 1,
7
7
  STALE = 2,
8
8
  }
9
+ export declare enum TraceMode {
10
+ NONE = 0,
11
+ LOG = 1,
12
+ BREAK = 2,
13
+ }
9
14
  /**
10
15
  * A derivation is everything that can be derived from the state (all the atoms) in a pure manner.
11
16
  * See https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
@@ -25,6 +30,7 @@ export interface IDerivation extends IDepTreeNode {
25
30
  unboundDepsCount: number;
26
31
  __mapid: string;
27
32
  onBecomeStale(): any;
33
+ isTracing: TraceMode;
28
34
  }
29
35
  export declare class CaughtException {
30
36
  cause: any;
@@ -1,4 +1,4 @@
1
- import { IDerivation, IDerivationState } from "./derivation";
1
+ import { IDerivation, IDerivationState, TraceMode } from "./derivation";
2
2
  import { IObservable } from "./observable";
3
3
  /**
4
4
  * Reactions are a special kind of derivations. Several things distinguishes them from normal reactive computations
@@ -20,6 +20,7 @@ import { IObservable } from "./observable";
20
20
  */
21
21
  export interface IReactionPublic {
22
22
  dispose(): void;
23
+ trace(enterBreakPoint?: boolean): void;
23
24
  }
24
25
  export interface IReactionDisposer {
25
26
  (): void;
@@ -40,6 +41,7 @@ export declare class Reaction implements IDerivation, IReactionPublic {
40
41
  _isScheduled: boolean;
41
42
  _isTrackPending: boolean;
42
43
  _isRunning: boolean;
44
+ isTracing: TraceMode;
43
45
  errorHandler: (error: any, derivation: IDerivation) => void;
44
46
  constructor(name: string, onInvalidate: () => void);
45
47
  onBecomeStale(): void;
@@ -55,6 +57,7 @@ export declare class Reaction implements IDerivation, IReactionPublic {
55
57
  getDisposer(): IReactionDisposer;
56
58
  toString(): string;
57
59
  whyRun(): string;
60
+ trace(enterBreakPoint?: boolean): void;
58
61
  }
59
62
  export declare function onReactionError(handler: (error: any, derivation: IDerivation) => void): () => void;
60
63
  export declare function runReactions(): void;
package/lib/mobx.d.ts CHANGED
@@ -44,88 +44,94 @@ export { action, isAction, runInAction, IActionFactory } from "./api/action";
44
44
  export { expr } from "./api/expr";
45
45
  export { toJS } from "./api/tojs";
46
46
  export { ITransformer, createTransformer } from "./api/createtransformer";
47
- export { whyRun } from "./api/whyrun";
47
+ export { whyRun, trace } from "./api/whyrun";
48
48
  export { Lambda, isArrayLike } from "./utils/utils";
49
49
  export { Iterator } from "./utils/iterable";
50
50
  export { IObserverTree, IDependencyTree } from "./api/extras";
51
- import { IDerivation } from "./core/derivation";
52
- import { IDepTreeNode } from "./core/observable";
53
- import { IObserverTree, IDependencyTree } from "./api/extras";
54
- import { Lambda } from "./utils/utils";
55
- import { IObservableArray } from "./types/observablearray";
51
+ import { resetGlobalState, shareGlobalState, getGlobalState, isolateGlobalState } from "./core/globalstate";
52
+ import { getDependencyTree, getObserverTree } from "./api/extras";
53
+ import { getDebugName, getAtom, getAdministration } from "./types/type-utils";
54
+ import { allowStateChanges } from "./core/action";
55
+ import { spyReport, spyReportEnd, spyReportStart, isSpyEnabled } from "./core/spy";
56
+ import { deepEqual } from "./utils/eq";
57
+ import { isComputingDerivation } from "./core/derivation";
58
+ import { setReactionScheduler, onReactionError } from "./core/reaction";
59
+ import { reserveArrayBuffer } from "./types/observablearray";
60
+ import { interceptReads } from "./api/intercept-read";
56
61
  import { ObservableMap } from "./types/observablemap";
57
62
  import { IObservableValue } from "./types/observablevalue";
58
63
  export 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;
64
+ allowStateChanges: typeof allowStateChanges;
65
+ deepEqual: typeof deepEqual;
66
+ getAtom: typeof getAtom;
67
+ getDebugName: typeof getDebugName;
68
+ getDependencyTree: typeof getDependencyTree;
69
+ getAdministration: typeof getAdministration;
70
+ getGlobalState: typeof getGlobalState;
71
+ getObserverTree: typeof getObserverTree;
72
+ interceptReads: typeof interceptReads;
73
+ isComputingDerivation: typeof isComputingDerivation;
74
+ isSpyEnabled: typeof isSpyEnabled;
75
+ onReactionError: typeof onReactionError;
76
+ reserveArrayBuffer: typeof reserveArrayBuffer;
77
+ resetGlobalState: typeof resetGlobalState;
78
+ isolateGlobalState: typeof isolateGlobalState;
79
+ shareGlobalState: typeof shareGlobalState;
80
+ spyReport: typeof spyReport;
81
+ spyReportEnd: typeof spyReportEnd;
82
+ spyReportStart: typeof spyReportStart;
83
+ setReactionScheduler: typeof setReactionScheduler;
84
84
  };
85
- import { Reaction, IReactionPublic, IReactionDisposer } from "./core/reaction";
85
+ import { Reaction } from "./core/reaction";
86
+ import { untracked } from "./core/derivation";
86
87
  import { Atom, BaseAtom } from "./core/atom";
87
- import { IComputedValue } from "./core/computedvalue";
88
- import { IModifierDescriptor } from "./types/modifiers";
89
- import { IInterceptor } from "./types/intercept-utils";
90
- import { IObjectWillChange, IObjectChange, IObservableObject } from "./types/observableobject";
91
- import { IValueDidChange, IValueWillChange } from "./types/observablevalue";
92
- import { IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice } from "./types/observablearray";
93
- import { IKeyValueMap, IMapWillChange, IMapChange, IMap } from "./types/observablemap";
88
+ import { useStrict, isStrictModeEnabled } from "./core/action";
89
+ import { spy } from "./core/spy";
90
+ import { asReference, asFlat, asStructure, asMap } from "./types/modifiers-old";
91
+ import { isModifierDescriptor } from "./types/modifiers";
92
+ import { isObservableObject } from "./types/observableobject";
93
+ import { isObservableArray } from "./types/observablearray";
94
+ import { map } from "./types/observablemap";
95
+ import { transaction } from "./api/transaction";
94
96
  import { IObservableFactory, IObservableFactories } from "./api/observable";
95
97
  import { IComputed } from "./api/computed";
96
- import { IReactionOptions } from "./api/autorun";
97
- import { IActionFactory } from "./api/action";
98
- import { ITransformer } from "./api/createtransformer";
98
+ import { isObservable } from "./api/isobservable";
99
+ import { isComputed } from "./api/iscomputed";
100
+ import { extendObservable, extendShallowObservable } from "./api/extendobservable";
101
+ import { observe } from "./api/observe";
102
+ import { intercept } from "./api/intercept";
103
+ import { autorun, autorunAsync, when, reaction } from "./api/autorun";
104
+ import { isAction, runInAction, IActionFactory } from "./api/action";
105
+ import { expr } from "./api/expr";
106
+ import { toJS } from "./api/tojs";
107
+ import { createTransformer } from "./api/createtransformer";
108
+ import { whyRun } from "./api/whyrun";
109
+ import { isArrayLike } from "./utils/utils";
99
110
  declare const everything: {
100
111
  Reaction: typeof Reaction;
101
- untracked: <T>(action: () => T) => T;
112
+ untracked: typeof untracked;
102
113
  Atom: typeof Atom;
103
114
  BaseAtom: typeof BaseAtom;
104
- useStrict: (strict: boolean) => void;
105
- isStrictModeEnabled: () => boolean;
106
- spy: (listener: (change: any) => void) => Lambda;
115
+ useStrict: typeof useStrict;
116
+ isStrictModeEnabled: typeof isStrictModeEnabled;
117
+ spy: typeof spy;
107
118
  comparer: {
108
119
  identity: (a: any, b: any) => boolean;
109
120
  structural: (a: any, b: any) => boolean;
110
121
  default: (a: any, b: any) => boolean;
111
122
  };
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
+ asReference: typeof asReference;
124
+ asFlat: typeof asFlat;
125
+ asStructure: typeof asStructure;
126
+ asMap: typeof asMap;
127
+ isModifierDescriptor: typeof isModifierDescriptor;
128
+ isObservableObject: typeof isObservableObject;
123
129
  isBoxedObservable: (x: any) => x is IObservableValue<any>;
124
- isObservableArray: (thing: any) => thing is IObservableArray<any>;
130
+ isObservableArray: typeof isObservableArray;
125
131
  ObservableMap: typeof ObservableMap;
126
132
  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;
133
+ map: typeof map;
134
+ transaction: typeof transaction;
129
135
  observable: IObservableFactory & IObservableFactories & {
130
136
  deep: {
131
137
  struct<T>(initialValue?: T | undefined): T;
@@ -135,83 +141,45 @@ declare const everything: {
135
141
  };
136
142
  };
137
143
  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
- };
144
+ isObservable: typeof isObservable;
145
+ isComputed: typeof isComputed;
146
+ extendObservable: typeof extendObservable;
147
+ extendShallowObservable: typeof extendShallowObservable;
148
+ observe: typeof observe;
149
+ intercept: typeof intercept;
150
+ autorun: typeof autorun;
151
+ autorunAsync: typeof autorunAsync;
152
+ when: typeof when;
153
+ reaction: typeof reaction;
174
154
  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>;
155
+ isAction: typeof isAction;
156
+ runInAction: typeof runInAction;
157
+ expr: typeof expr;
158
+ toJS: typeof toJS;
159
+ createTransformer: typeof createTransformer;
160
+ whyRun: typeof whyRun;
161
+ isArrayLike: typeof isArrayLike;
189
162
  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;
163
+ allowStateChanges: typeof allowStateChanges;
164
+ deepEqual: typeof deepEqual;
165
+ getAtom: typeof getAtom;
166
+ getDebugName: typeof getDebugName;
167
+ getDependencyTree: typeof getDependencyTree;
168
+ getAdministration: typeof getAdministration;
169
+ getGlobalState: typeof getGlobalState;
170
+ getObserverTree: typeof getObserverTree;
171
+ interceptReads: typeof interceptReads;
172
+ isComputingDerivation: typeof isComputingDerivation;
173
+ isSpyEnabled: typeof isSpyEnabled;
174
+ onReactionError: typeof onReactionError;
175
+ reserveArrayBuffer: typeof reserveArrayBuffer;
176
+ resetGlobalState: typeof resetGlobalState;
177
+ isolateGlobalState: typeof isolateGlobalState;
178
+ shareGlobalState: typeof shareGlobalState;
179
+ spyReport: typeof spyReport;
180
+ spyReportEnd: typeof spyReportEnd;
181
+ spyReportStart: typeof spyReportStart;
182
+ setReactionScheduler: typeof setReactionScheduler;
215
183
  };
216
184
  };
217
185
  export default everything;