mobx 5.10.1 → 5.14.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 +29 -1
- package/LICENSE +0 -0
- package/README.md +66 -52
- package/lib/api/action.d.ts +0 -0
- package/lib/api/actiondecorator.d.ts +0 -0
- package/lib/api/autorun.d.ts +5 -0
- package/lib/api/become-observed.d.ts +0 -0
- package/lib/api/computed.d.ts +0 -0
- package/lib/api/configure.d.ts +11 -0
- package/lib/api/decorate.d.ts +0 -0
- package/lib/api/extendobservable.d.ts +0 -0
- package/lib/api/extras.d.ts +0 -0
- package/lib/api/flow.d.ts +0 -0
- package/lib/api/intercept-read.d.ts +0 -0
- package/lib/api/intercept.d.ts +0 -0
- package/lib/api/iscomputed.d.ts +0 -0
- package/lib/api/isobservable.d.ts +0 -0
- package/lib/api/object-api.d.ts +2 -2
- package/lib/api/observable.d.ts +0 -0
- package/lib/api/observabledecorator.d.ts +0 -0
- package/lib/api/observe.d.ts +0 -0
- package/lib/api/tojs.d.ts +0 -0
- package/lib/api/trace.d.ts +0 -0
- package/lib/api/transaction.d.ts +0 -0
- package/lib/api/when.d.ts +5 -0
- package/lib/core/action.d.ts +13 -0
- package/lib/core/atom.d.ts +2 -2
- package/lib/core/computedvalue.d.ts +0 -0
- package/lib/core/derivation.d.ts +7 -0
- package/lib/core/globalstate.d.ts +22 -0
- package/lib/core/observable.d.ts +0 -0
- package/lib/core/reaction.d.ts +2 -1
- package/lib/core/spy.d.ts +0 -0
- package/lib/internal.d.ts +0 -0
- package/lib/mobx.d.ts +1 -1
- package/lib/mobx.es6.js +471 -382
- package/lib/mobx.js +485 -371
- package/lib/mobx.js.flow +20 -2
- package/lib/mobx.min.js +1 -1
- package/lib/mobx.module.js +485 -373
- package/lib/mobx.umd.js +485 -371
- package/lib/mobx.umd.min.js +1 -1
- package/lib/types/dynamicobject.d.ts +0 -0
- package/lib/types/intercept-utils.d.ts +0 -0
- package/lib/types/listen-utils.d.ts +0 -0
- package/lib/types/modifiers.d.ts +0 -0
- package/lib/types/observablearray.d.ts +0 -0
- package/lib/types/observablemap.d.ts +0 -0
- package/lib/types/observableobject.d.ts +0 -0
- package/lib/types/observableset.d.ts +0 -0
- package/lib/types/observablevalue.d.ts +0 -0
- package/lib/types/type-utils.d.ts +0 -0
- package/lib/utils/comparer.d.ts +0 -0
- package/lib/utils/decorators.d.ts +0 -0
- package/lib/utils/eq.d.ts +0 -0
- package/lib/utils/iterable.d.ts +0 -0
- package/lib/utils/utils.d.ts +0 -0
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# 5.14.0 / 4.14.0
|
|
2
|
+
|
|
3
|
+
* Added experimental `reactionRequiresObservable` & `observableRequiresReaction` config [#2079](https://github.com/mobxjs/mobx/pull/2079), [Docs](https://github.com/mobxjs/mobx/pull/2082)
|
|
4
|
+
* Added experimental `requiresObservable` config to `reaction`, `autorun` & `when` options [#2079](https://github.com/mobxjs/mobx/pull/2079), [Docs](https://github.com/mobxjs/mobx/pull/2082)
|
|
5
|
+
|
|
6
|
+
# 5.13.1 / 4.13.1
|
|
7
|
+
|
|
8
|
+
* Don't use `global` and `self` keywords unless defined. Fixes [#2070](https://github.com/mobxjs/mobx/issues/2070).
|
|
9
|
+
* onBecome(Un)Observed didn't trigger when using number as key of observable map. Fixes [#2067](https://github.com/mobxjs/mobx/issues/2067).
|
|
10
|
+
* Exposed `_startAction` and `_endAction` to be able to start and action and finish it without needing a code block. This is low level stuff you shouldn't need that's mostly useful for library creators.
|
|
11
|
+
|
|
12
|
+
# 5.13.0 / 4.13.0
|
|
13
|
+
|
|
14
|
+
* Fixed potential memory leak in observable maps, when non-primitive values are used as keys. Fixes [#2031](https://github.com/mobxjs/mobx/issues/2031) through [#2032](https://github.com/mobxjs/mobx/pull/2032).
|
|
15
|
+
* Added support to store additional non-observable(!) fields (string or symbol based) on array, to better reflect behavior of MobX 4. Fixes [#2044](https://github.com/mobxjs/mobx/issues/2044) through [#2046](https://github.com/mobxjs/mobx/pull/2046)
|
|
16
|
+
|
|
17
|
+
# 5.11.0 / 4.12.0
|
|
18
|
+
|
|
19
|
+
* Added `computedConfigurable` config [#2011](https://github.com/mobxjs/mobx/pull/2011), [#2013](https://github.com/mobxjs/mobx/pull/2014)
|
|
20
|
+
|
|
21
|
+
# 4.11.0
|
|
22
|
+
|
|
23
|
+
**BREAKING CHANGE**
|
|
24
|
+
|
|
25
|
+
Reverted the support of Symbols in general in MobX 4, as it gives to many potential build errors and increases the system requirements for MobX 4 (which was an oversight in 4.10.0). Apologies for the breaking change (lack of new major version numbers). If lock files are properly used however, no harm should be caused by this change.
|
|
26
|
+
|
|
27
|
+
* Reverted `Symbol` support in observable maps and objects. Reverts [#1944](https://github.com/mobxjs/mobx/pull/1944) through [#1988](https://github.com/mobxjs/mobx/pull/1988). Fixes [#1986](https://github.com/mobxjs/mobx/issues/1986), [#1987](https://github.com/mobxjs/mobx/issues/1987)
|
|
28
|
+
|
|
1
29
|
# 5.10.1
|
|
2
30
|
|
|
3
31
|
* Fixed a recent regression where array update events would send undefined as `change.object` through [#1985](https://github.com/mobxjs/mobx/pull/1985) by [xaviergonz](https://github.com/xaviergonz)
|
|
@@ -143,7 +171,7 @@ MobX 5 is the first MobX version fully leveraging Proxies. This has two big adva
|
|
|
143
171
|
|
|
144
172
|
### The system requirements to run MobX has been upped
|
|
145
173
|
|
|
146
|
-
* MobX 5 can only be used on environments that support `Proxies`.
|
|
174
|
+
* MobX 5 can only be used on environments that support `Proxies`. See the [browser support](https://github.com/mobxjs/mobx#browser-support) for details.
|
|
147
175
|
* Since MobX no longer runs on older browsers, the compilation target has been upgraded to ES2015 syntax supporting browsers. This means that MobX is not loadable on older browsers without down compilation to ES5.
|
|
148
176
|
* If for whatever reason your project cannot meet this requirements, please stick to MobX 4. It will be actively maintained. All current features of MobX 5 are expressable in MobX 4 as well, but it means that for example to use dynamic objects some [additional APIs](https://mobx.js.org/refguide/object-api.html) are needed.
|
|
149
177
|
* The performance footprint of MobX 5 should be pretty similar to MobX 4. In our performance tests we saw some minor improvements in memory footprint, but overall it should be pretty comparable.
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
_Simple, scalable state management_
|
|
6
6
|
|
|
7
|
-
[](https://circleci.com/gh/mobxjs/mobx)
|
|
8
8
|
[](https://coveralls.io/github/mobxjs/mobx?branch=master)
|
|
9
9
|
[](https://gitter.im/mobxjs/mobx?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
10
10
|
[](https://hashnode.com/n/mobx)
|
|
@@ -12,60 +12,72 @@ _Simple, scalable state management_
|
|
|
12
12
|
[](#sponsors)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
14
|
|
|
15
|
-
MobX is proudly sponsored by Mendix, Coinbase, Facebook Open Source, Canva, Algolia, Guilded, Auction Frontier, Mantro and TalentPlot for 100
|
|
15
|
+
MobX is proudly sponsored by Mendix, Coinbase, Facebook Open Source, Canva, Algolia, Guilded, Auction Frontier, Mantro and TalentPlot for 100\$/month or more! And beyond that by many [individual backers](#backers) and through [one time contributions](https://github.com/mobxjs/mobx/blob/master/sponsors.md).
|
|
16
16
|
|
|
17
|
+
**🥇Gold sponsors (\$250+ pm):** <br/>
|
|
17
18
|
<a href="https://mendix.com/"><img src="docs/mendix-logo.png" align="center" width="100" title="Mendix" alt="Mendix" /></a>
|
|
18
|
-
<a href="
|
|
19
|
+
<a href="http://auctionfrontier.com/"><img src="docs/auctionfrontier.jpeg" align="center" width="100" title="Auction Frontier" alt="Auction Frontier"></a>
|
|
20
|
+
|
|
21
|
+
**🥈Silver sponsors (\$100+ pm):**<br/>
|
|
19
22
|
<a href="https://opensource.facebook.com/"><img src="docs/fbos.jpeg" align="center" width="100" title="Facebook Open Source" alt="Facebook Open Source" /></a>
|
|
20
23
|
<a href="https://www.canva.com/"><img src="docs/canva.png" align="center" width="100" title="Canva" alt="Canva" /></a>
|
|
21
|
-
<a href="https://www.algolia.com/"><img src="docs/algolia.jpg" align="center" width="100" title="Algolia" alt="Algolia" /></a>
|
|
22
24
|
<a href="https://www.guilded.gg/"><img src="docs/guilded.jpg" align="center" width="100" title="Guilded" alt="Guilded" /></a>
|
|
23
|
-
<a href="http://auctionfrontier.com/"><img src="docs/auctionfrontier.jpeg" align="center" width="100" title="Auction Frontier" alt="Auction Frontier"></a>
|
|
24
25
|
<a href="https://mantro.net/jobs/warlock"><img src="docs/mantro.png" align="center" width="100" title="mantro GmbH" alt="mantro GmbH"></a>
|
|
25
|
-
<a href="https://talentplot.com/"><img src="docs/talentplot.png" align="center" width="100" title="talentplot" alt="talentplot"></a>
|
|
26
26
|
<a href="https://www.codefirst.co.uk/"><img src="https://mobx.js.org/docs/codefirst.png" align="center" width="100" title="CodeFirst" alt="CodeFirst"/></a>
|
|
27
27
|
<a href="https://blokt.com/"><img src="https://mobx.js.org/docs/blokt.jpg" align="center" width="100" title="Blokt" alt="Blokt"/></a>
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
**🥉Bronze sponsors:**<br/>
|
|
30
|
+
<a href="https://coinbase.com/"><img src="docs/coinbase.jpeg" align="center" width="100" title="Coinbase" alt="Coinbase" /></a>
|
|
31
|
+
<a href="https://www.algolia.com/"><img src="docs/algolia.jpg" align="center" width="100" title="Algolia" alt="Algolia" /></a>
|
|
32
|
+
<a href="https://talentplot.com/"><img src="docs/talentplot.png" align="center" width="100" title="talentplot" alt="talentplot"></a>
|
|
29
33
|
|
|
30
34
|
# Installation
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
- Installation: `npm install mobx --save`. React bindings: `npm install mobx-react --save`. To enable ESNext decorators (optional), see below.
|
|
37
|
+
- CDN:
|
|
38
|
+
- https://unpkg.com/mobx/lib/mobx.umd.js
|
|
39
|
+
- https://cdnjs.com/libraries/mobx
|
|
36
40
|
|
|
37
41
|
_Tip: Consider using the faster and smaller ES6 build if targetting a modern environment: `lib/mobx.es6.js`. For example by setting up a webpack alias: `resolve: { alias: { mobx: __dirname + "/node_modules/mobx/lib/mobx.es6.js" }}`_
|
|
38
42
|
|
|
39
43
|
# Browser support
|
|
40
44
|
|
|
41
|
-
| MobX version | Actively supported | Supported browsers
|
|
42
|
-
| ------------ | ------------------ |
|
|
45
|
+
| MobX version | Actively supported | Supported browsers | GitHub branch |
|
|
46
|
+
| ------------ | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
|
|
43
47
|
| 5.\* | Yes | Any browser that supports [ES6 Proxies](https://kangax.github.io/compat-table/es6/#test-Proxy) (non polyfillable). _NOT:_ IE 11 and lower, Node 5 and lower | `master` |
|
|
44
|
-
| 4.\* | Yes (LTS) | Any ES5 compliant browser
|
|
45
|
-
| 1-3.\* | No | Any ES5 compliant browser
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
| 4.\* | Yes (LTS) | Any ES5 compliant browser | `mobx4-master` |
|
|
49
|
+
| 1-3.\* | No | Any ES5 compliant browser | No active branch |
|
|
50
|
+
|
|
51
|
+
- All modern browsers are supported.
|
|
52
|
+
- MobX >=5 runs on any browser with [ES6 proxy support](https://kangax.github.io/compat-table/es6/#test-Proxy). In practice this means:
|
|
53
|
+
- no Internet Explorer (Edge is fine)
|
|
54
|
+
- Node.js >= 6
|
|
55
|
+
- React Native:
|
|
56
|
+
- iOS >= 10
|
|
57
|
+
- Android from RN 0.59 (or with manual JavaScript core [upgrade](https://github.com/react-community/jsc-android-buildscripts#how-to-use-it-with-my-react-native-app))
|
|
58
|
+
- Hermes runtime is [not supported](https://github.com/facebook/hermes/issues/28) (Use MobX 4 instead)
|
|
59
|
+
- MobX 4 runs on any ES5 browser and will be actively maintained. The MobX 4 and 5 api's are the same and semantically can achieve the same, but MobX 4 has some [limitations](#mobx-4-vs-mobx-5).
|
|
60
|
+
- The latest versions of libraries like mobx-react, mobx-react-lite, mobx-state-tree etc are kept compatible with both MobX 4 and 5.
|
|
49
61
|
|
|
50
62
|
## Translations
|
|
51
63
|
|
|
52
|
-
|
|
64
|
+
- [中文](http://cn.mobx.js.org)
|
|
53
65
|
|
|
54
66
|
## Getting started
|
|
55
67
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
- <i><a style="color: white; background:green;padding:5px;margin:5px;border-radius:2px" href="https://egghead.io/courses/manage-complex-state-in-react-apps-with-mobx">Egghead.io course</a></i>
|
|
69
|
+
- [Ten minute, interactive MobX + React tutorial](https://mobxjs.github.io/mobx/getting-started.html)
|
|
70
|
+
- <img src="docs/book.jpg" height="80px"/> [The MobX book](https://books.google.nl/books?id=ALFmDwAAQBAJ&pg=PP1&lpg=PP1&dq=michel+weststrate+mobx+quick+start+guide:+supercharge+the+client+state+in+your+react+apps+with+mobx&source=bl&ots=D460fxti0F&sig=ivDGTxsPNwlOjLHrpKF1nweZFl8&hl=nl&sa=X&ved=2ahUKEwiwl8XO--ncAhWPmbQKHWOYBqIQ6AEwAnoECAkQAQ#v=onepage&q=michel%20weststrate%20mobx%20quick%20start%20guide%3A%20supercharge%20the%20client%20state%20in%20your%20react%20apps%20with%20mobx&f=false) by Pavan Podila and Michel Weststrate (which despite it's name is in-depth!)
|
|
71
|
+
- [Official MobX 4 documentation and API overview](https://mobxjs.github.io/mobx/refguide/api.html) ([MobX 3](https://github.com/mobxjs/mobx/blob/54557dc319b04e92e31cb87427bef194ec1c549c/docs/refguide/api.md), [MobX 2](https://github.com/mobxjs/mobx/blob/7c9e7c86e0c6ead141bb0539d33143d0e1f576dd/docs/refguide/api.md))
|
|
72
|
+
- [How to (not) use decorators](https://mobx.js.org/best/decorators.html)
|
|
73
|
+
- Videos:
|
|
74
|
+
- [ReactNext 2016: Real World MobX](https://www.youtube.com/watch?v=Aws40KOx90U) - 40m [slides](https://docs.google.com/presentation/d/1DrI6Hc2xIPTLBkfNH8YczOcPXQTOaCIcDESdyVfG_bE/edit?usp=sharing)
|
|
75
|
+
- [Practical React with MobX](https://www.youtube.com/watch?v=XGwuM_u7UeQ). In depth introduction and explanation to MobX and React by Matt Ruby on OpenSourceNorth (ES5 only) - 42m.
|
|
76
|
+
- LearnCode.academy MobX tutorial [Part I: MobX + React is AWESOME (7m)](https://www.youtube.com/watch?v=_q50BXqkAfI) [Part II: Computed Values and Nested/Referenced Observables (12m.)](https://www.youtube.com/watch?v=nYvNqKrl69s)
|
|
77
|
+
- [Screencast: intro to MobX](https://www.youtube.com/watch?v=K8dr8BMU7-8) - 8m
|
|
78
|
+
- [Talk: State Management Is Easy, React Amsterdam 2016 conf](https://www.youtube.com/watch?v=ApmSsu3qnf0&feature=youtu.be) ([slides](https://speakerdeck.com/mweststrate/state-management-is-easy-introduction-to-mobx))
|
|
79
|
+
- [Boilerplates and related projects](http://mobxjs.github.io/mobx/faq/boilerplates.html)
|
|
80
|
+
- More tutorials, blogs, videos, and other helpful resources can be found on the [MobX awesome list](https://github.com/mobxjs/awesome-mobx#awesome-mobx)
|
|
69
81
|
|
|
70
82
|
## Introduction
|
|
71
83
|
|
|
@@ -168,7 +180,9 @@ class TodoListView extends Component {
|
|
|
168
180
|
return (
|
|
169
181
|
<div>
|
|
170
182
|
<ul>
|
|
171
|
-
{this.props.todoList.todos.map(todo =>
|
|
183
|
+
{this.props.todoList.todos.map(todo => (
|
|
184
|
+
<TodoView todo={todo} key={todo.id} />
|
|
185
|
+
))}
|
|
172
186
|
</ul>
|
|
173
187
|
Tasks left: {this.props.todoList.unfinishedTodoCount}
|
|
174
188
|
</div>
|
|
@@ -223,9 +237,9 @@ For an in-depth explanation about how MobX determines to which observables needs
|
|
|
223
237
|
|
|
224
238
|
Unlike many flux frameworks, MobX is unopinionated about how user events should be handled.
|
|
225
239
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
240
|
+
- This can be done in a Flux like manner.
|
|
241
|
+
- Or by processing events using RxJS.
|
|
242
|
+
- Or by simply handling events in the most straightforward way possible, as demonstrated in the above `onClick` handler.
|
|
229
243
|
|
|
230
244
|
In the end it all boils down to: somehow the state should be updated.
|
|
231
245
|
|
|
@@ -294,12 +308,12 @@ And finally, kudos to all the people that believed in, tried, validated and even
|
|
|
294
308
|
|
|
295
309
|
## Further resources and documentation
|
|
296
310
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
311
|
+
- <img src="docs/book.jpg" height="80px"/> [The MobX book](https://books.google.nl/books?id=ALFmDwAAQBAJ&pg=PP1&lpg=PP1&dq=michel+weststrate+mobx+quick+start+guide:+supercharge+the+client+state+in+your+react+apps+with+mobx&source=bl&ots=D460fxti0F&sig=ivDGTxsPNwlOjLHrpKF1nweZFl8&hl=nl&sa=X&ved=2ahUKEwiwl8XO--ncAhWPmbQKHWOYBqIQ6AEwAnoECAkQAQ#v=onepage&q=michel%20weststrate%20mobx%20quick%20start%20guide%3A%20supercharge%20the%20client%20state%20in%20your%20react%20apps%20with%20mobx&f=false) by Pavan Podila and Michel Weststrate (which despite it's name is in-depth!)
|
|
312
|
+
- [MobX homepage](http://mobxjs.github.io/mobx/faq/blogs.html)
|
|
313
|
+
- [API overview](http://mobxjs.github.io/mobx/refguide/api.html)
|
|
314
|
+
- [Tutorials, Blogs & Videos](http://mobxjs.github.io/mobx/faq/blogs.html)
|
|
315
|
+
- [Boilerplates](http://mobxjs.github.io/mobx/faq/boilerplates.html)
|
|
316
|
+
- [Related projects](http://mobxjs.github.io/mobx/faq/related.html)
|
|
303
317
|
|
|
304
318
|
## What others are saying...
|
|
305
319
|
|
|
@@ -319,11 +333,11 @@ And finally, kudos to all the people that believed in, tried, validated and even
|
|
|
319
333
|
|
|
320
334
|
## Contributing
|
|
321
335
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
336
|
+
- Feel free to send small pull requests. Please discuss new features or big changes in a GitHub issue first.
|
|
337
|
+
- Use `yarn test` to run the basic test suite.
|
|
338
|
+
- Use `yarn test:ci` for the test suite with coverage.
|
|
339
|
+
- and `yarn test:performance` for the performance tests.
|
|
340
|
+
- Please note that if you want to backport a feature / fix to MobX 4 a second PR needs to be opened to the mobx4-master branch.
|
|
327
341
|
|
|
328
342
|
# MobX 4 vs MobX 5
|
|
329
343
|
|
|
@@ -331,8 +345,8 @@ The difference between MobX 4 and MobX 5 is that the latter uses Proxies to do p
|
|
|
331
345
|
|
|
332
346
|
The most notable limitations of MobX 4:
|
|
333
347
|
|
|
334
|
-
|
|
335
|
-
|
|
348
|
+
- Observable arrays are not real arrays, so they won't pass the `Array.isArray()` check. The practical consequence is that you often need to `.slice()` the array first (to get a real array shallow copy) before passing to third party libraries.
|
|
349
|
+
- Adding properties to existing observable objects after creation is not automatically picked up. Instead, either use observable maps or use the the built-in [utility functions](https://mobx.js.org/refguide/object-api.html) to read / write / iterate objects that you want to dynamically add properties to.
|
|
336
350
|
|
|
337
351
|
For more details see the [caveats page](https://mobx.js.org/best/pitfalls.html).
|
|
338
352
|
|
|
@@ -342,9 +356,9 @@ MobX ships with [flow typings](flow-typed/mobx.js). Flow will automatically incl
|
|
|
342
356
|
|
|
343
357
|
To use the [flow typings](flow-typed/mobx.js) shipped with MobX:
|
|
344
358
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
359
|
+
- In `.flowconfig`, you **cannot** ignore `node_modules`.
|
|
360
|
+
- In `.flowconfig`, you **cannot** import it explicitly in the `[libs]` section.
|
|
361
|
+
- You **do not** need to install library definition using [flow-typed](https://github.com/flowtype/flow-typed).
|
|
348
362
|
|
|
349
363
|
## Donating
|
|
350
364
|
|
package/lib/api/action.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/api/autorun.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { IEqualsComparer, IReactionDisposer, IReactionPublic } from "../internal
|
|
|
2
2
|
export interface IAutorunOptions {
|
|
3
3
|
delay?: number;
|
|
4
4
|
name?: string;
|
|
5
|
+
/**
|
|
6
|
+
* Experimental.
|
|
7
|
+
* Warns if the view doesn't track observables
|
|
8
|
+
*/
|
|
9
|
+
requiresObservable?: boolean;
|
|
5
10
|
scheduler?: (callback: () => void) => any;
|
|
6
11
|
onError?: (error: any) => void;
|
|
7
12
|
}
|
|
File without changes
|
package/lib/api/computed.d.ts
CHANGED
|
File without changes
|
package/lib/api/configure.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
export declare function configure(options: {
|
|
2
2
|
enforceActions?: boolean | "strict" | "never" | "always" | "observed";
|
|
3
3
|
computedRequiresReaction?: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* (Experimental)
|
|
6
|
+
* Warn if you try to create to derivation / reactive context without accessing any observable.
|
|
7
|
+
*/
|
|
8
|
+
reactionRequiresObservable?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* (Experimental)
|
|
11
|
+
* Warn if observables are accessed outside a reactive context
|
|
12
|
+
*/
|
|
13
|
+
observableRequiresReaction?: boolean;
|
|
14
|
+
computedConfigurable?: boolean;
|
|
4
15
|
isolateGlobalState?: boolean;
|
|
5
16
|
disableErrorBoundaries?: boolean;
|
|
6
17
|
reactionScheduler?: (f: () => void) => void;
|
package/lib/api/decorate.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/api/extras.d.ts
CHANGED
|
File without changes
|
package/lib/api/flow.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/api/intercept.d.ts
CHANGED
|
File without changes
|
package/lib/api/iscomputed.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/api/object-api.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ export declare function keys<T extends Object>(obj: T): ReadonlyArray<PropertyKe
|
|
|
6
6
|
export declare function values<K, T>(map: ObservableMap<K, T>): ReadonlyArray<T>;
|
|
7
7
|
export declare function values<T>(set: ObservableSet<T>): ReadonlyArray<T>;
|
|
8
8
|
export declare function values<T>(ar: IObservableArray<T>): ReadonlyArray<T>;
|
|
9
|
-
export declare function values<T = any>(obj: T): ReadonlyArray<any>;
|
|
9
|
+
export declare function values<T = any>(obj: T): ReadonlyArray<T extends object ? T[keyof T] : any>;
|
|
10
10
|
export declare function entries<K, T>(map: ObservableMap<K, T>): ReadonlyArray<[K, T]>;
|
|
11
11
|
export declare function entries<T>(set: ObservableSet<T>): ReadonlyArray<[T, T]>;
|
|
12
12
|
export declare function entries<T>(ar: IObservableArray<T>): ReadonlyArray<[number, T]>;
|
|
13
|
-
export declare function entries<T = any>(obj: T): ReadonlyArray<[string, any]>;
|
|
13
|
+
export declare function entries<T = any>(obj: T): ReadonlyArray<[string, T extends object ? T[keyof T] : any]>;
|
|
14
14
|
export declare function set<V>(obj: ObservableMap<PropertyKey, V>, values: {
|
|
15
15
|
[key: string]: V;
|
|
16
16
|
}): any;
|
package/lib/api/observable.d.ts
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/api/observe.d.ts
CHANGED
|
File without changes
|
package/lib/api/tojs.d.ts
CHANGED
|
File without changes
|
package/lib/api/trace.d.ts
CHANGED
|
File without changes
|
package/lib/api/transaction.d.ts
CHANGED
|
File without changes
|
package/lib/api/when.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { IReactionDisposer, Lambda } from "../internal";
|
|
|
2
2
|
export interface IWhenOptions {
|
|
3
3
|
name?: string;
|
|
4
4
|
timeout?: number;
|
|
5
|
+
/**
|
|
6
|
+
* Experimental.
|
|
7
|
+
* Warns if the view doesn't track observables
|
|
8
|
+
*/
|
|
9
|
+
requiresObservable?: boolean;
|
|
5
10
|
onError?: (error: any) => void;
|
|
6
11
|
}
|
|
7
12
|
export declare function when(predicate: () => boolean, opts?: IWhenOptions): Promise<void> & {
|
package/lib/core/action.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
import { IDerivation } from "../internal";
|
|
1
2
|
export interface IAction {
|
|
2
3
|
isMobxAction: boolean;
|
|
3
4
|
}
|
|
4
5
|
export declare function createAction(actionName: string, fn: Function, ref?: Object): Function & IAction;
|
|
5
6
|
export declare function executeAction(actionName: string, fn: Function, scope?: any, args?: IArguments): any;
|
|
7
|
+
export interface IActionRunInfo {
|
|
8
|
+
prevDerivation: IDerivation | null;
|
|
9
|
+
prevAllowStateChanges: boolean;
|
|
10
|
+
prevAllowStateReads: boolean;
|
|
11
|
+
notifySpy: boolean;
|
|
12
|
+
startTime: number;
|
|
13
|
+
error?: any;
|
|
14
|
+
parentActionId: number;
|
|
15
|
+
actionId: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function _startAction(actionName: string, scope: any, args?: IArguments): IActionRunInfo;
|
|
18
|
+
export declare function _endAction(runInfo: IActionRunInfo): void;
|
|
6
19
|
export declare function allowStateChanges<T>(allowStateChanges: boolean, func: () => T): T;
|
|
7
20
|
export declare function allowStateChangesStart(allowStateChanges: boolean): boolean;
|
|
8
21
|
export declare function allowStateChangesEnd(prev: boolean): void;
|
package/lib/core/atom.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDerivationState, IObservable } from "../internal";
|
|
1
|
+
import { IDerivationState, IObservable, IDerivation } from "../internal";
|
|
2
2
|
import { Lambda } from "../utils/utils";
|
|
3
3
|
export declare const $mobx: unique symbol;
|
|
4
4
|
export interface IAtom extends IObservable {
|
|
@@ -9,7 +9,7 @@ export declare class Atom implements IAtom {
|
|
|
9
9
|
name: string;
|
|
10
10
|
isPendingUnobservation: boolean;
|
|
11
11
|
isBeingObserved: boolean;
|
|
12
|
-
observers: Set<
|
|
12
|
+
observers: Set<IDerivation>;
|
|
13
13
|
diffValue: number;
|
|
14
14
|
lastAccessedBy: number;
|
|
15
15
|
lowestObserverState: IDerivationState;
|
|
File without changes
|
package/lib/core/derivation.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ export interface IDerivation extends IDepTreeNode {
|
|
|
30
30
|
__mapid: string;
|
|
31
31
|
onBecomeStale(): void;
|
|
32
32
|
isTracing: TraceMode;
|
|
33
|
+
/**
|
|
34
|
+
* warn if the derivation has no dependencies after creation/update
|
|
35
|
+
*/
|
|
36
|
+
requiresObservable?: boolean;
|
|
33
37
|
}
|
|
34
38
|
export declare class CaughtException {
|
|
35
39
|
cause: any;
|
|
@@ -50,6 +54,7 @@ export declare function isCaughtException(e: any): e is CaughtException;
|
|
|
50
54
|
export declare function shouldCompute(derivation: IDerivation): boolean;
|
|
51
55
|
export declare function isComputingDerivation(): boolean;
|
|
52
56
|
export declare function checkIfStateModificationsAreAllowed(atom: IAtom): void;
|
|
57
|
+
export declare function checkIfStateReadsAreAllowed(observable: IObservable): void;
|
|
53
58
|
/**
|
|
54
59
|
* Executes the provided function `f` and tracks which observables are being accessed.
|
|
55
60
|
* The tracking information is stored on the `derivation` object and the derivation is registered
|
|
@@ -60,6 +65,8 @@ export declare function clearObserving(derivation: IDerivation): void;
|
|
|
60
65
|
export declare function untracked<T>(action: () => T): T;
|
|
61
66
|
export declare function untrackedStart(): IDerivation | null;
|
|
62
67
|
export declare function untrackedEnd(prev: IDerivation | null): void;
|
|
68
|
+
export declare function allowStateReadsStart(allowStateReads: boolean): boolean;
|
|
69
|
+
export declare function allowStateReadsEnd(prev: boolean): void;
|
|
63
70
|
/**
|
|
64
71
|
* needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
|
|
65
72
|
*
|
|
@@ -55,6 +55,11 @@ export declare class MobXGlobals {
|
|
|
55
55
|
* To ensure that those functions stay pure.
|
|
56
56
|
*/
|
|
57
57
|
allowStateChanges: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Is it allowed to read observables at this point?
|
|
60
|
+
* Used to hold the state needed for `observableRequiresReaction`
|
|
61
|
+
*/
|
|
62
|
+
allowStateReads: boolean;
|
|
58
63
|
/**
|
|
59
64
|
* If strict mode is enabled, state changes are by default not allowed
|
|
60
65
|
*/
|
|
@@ -73,8 +78,25 @@ export declare class MobXGlobals {
|
|
|
73
78
|
* Warn if computed values are accessed outside a reactive context
|
|
74
79
|
*/
|
|
75
80
|
computedRequiresReaction: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* (Experimental)
|
|
83
|
+
* Warn if you try to create to derivation / reactive context without accessing any observable.
|
|
84
|
+
*/
|
|
85
|
+
reactionRequiresObservable: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* (Experimental)
|
|
88
|
+
* Warn if observables are accessed outside a reactive context
|
|
89
|
+
*/
|
|
90
|
+
observableRequiresReaction: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Allows overwriting of computed properties, useful in tests but not prod as it can cause
|
|
93
|
+
* memory leaks. See https://github.com/mobxjs/mobx/issues/1867
|
|
94
|
+
*/
|
|
95
|
+
computedConfigurable: boolean;
|
|
76
96
|
disableErrorBoundaries: boolean;
|
|
77
97
|
suppressReactionErrors: boolean;
|
|
98
|
+
currentActionId: number;
|
|
99
|
+
nextActionId: number;
|
|
78
100
|
}
|
|
79
101
|
export declare let globalState: MobXGlobals;
|
|
80
102
|
export declare function isolateGlobalState(): void;
|
package/lib/core/observable.d.ts
CHANGED
|
File without changes
|
package/lib/core/reaction.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare class Reaction implements IDerivation, IReactionPublic {
|
|
|
29
29
|
name: string;
|
|
30
30
|
private onInvalidate;
|
|
31
31
|
private errorHandler?;
|
|
32
|
+
requiresObservable: boolean;
|
|
32
33
|
observing: IObservable[];
|
|
33
34
|
newObserving: IObservable[];
|
|
34
35
|
dependenciesState: IDerivationState;
|
|
@@ -41,7 +42,7 @@ export declare class Reaction implements IDerivation, IReactionPublic {
|
|
|
41
42
|
_isTrackPending: boolean;
|
|
42
43
|
_isRunning: boolean;
|
|
43
44
|
isTracing: TraceMode;
|
|
44
|
-
constructor(name: string, onInvalidate: () => void, errorHandler?: ((error: any, derivation: IDerivation) => void) | undefined);
|
|
45
|
+
constructor(name: string, onInvalidate: () => void, errorHandler?: ((error: any, derivation: IDerivation) => void) | undefined, requiresObservable?: boolean);
|
|
45
46
|
onBecomeStale(): void;
|
|
46
47
|
schedule(): void;
|
|
47
48
|
isScheduled(): boolean;
|
package/lib/core/spy.d.ts
CHANGED
|
File without changes
|
package/lib/internal.d.ts
CHANGED
|
File without changes
|
package/lib/mobx.d.ts
CHANGED
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* - utils/ Utility stuff.
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
|
-
export { IObservable, IDepTreeNode, Reaction, IReactionPublic, IReactionDisposer, IDerivation, untracked, IDerivationState, IAtom, createAtom, IAction, spy, IComputedValue, IEqualsComparer, comparer, IEnhancer, IInterceptable, IInterceptor, IListenable, IObjectWillChange, IObjectDidChange, IObservableObject, isObservableObject, IValueDidChange, IValueWillChange, IObservableValue, isObservableValue as isBoxedObservable, IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice, isObservableArray, IKeyValueMap, ObservableMap, IMapEntries, IMapEntry, IMapWillChange, IMapDidChange, isObservableMap, IObservableMapInitialValues, ObservableSet, isObservableSet, ISetDidChange, ISetWillChange, IObservableSetInitialValues, transaction, observable, IObservableFactory, IObservableFactories, computed, IComputed, isObservable, isObservableProp, isComputed, isComputedProp, extendObservable, observe, intercept, autorun, IAutorunOptions, reaction, IReactionOptions, when, IWhenOptions, action, isAction, runInAction, IActionFactory, keys, values, entries, set, remove, has, get, decorate, configure, onBecomeObserved, onBecomeUnobserved, flow, toJS, trace, IObserverTree, IDependencyTree, getDependencyTree, getObserverTree, resetGlobalState as _resetGlobalState, getGlobalState as _getGlobalState, getDebugName, getAtom, getAdministration as _getAdministration, allowStateChanges as _allowStateChanges, allowStateChangesInsideComputed as _allowStateChangesInsideComputed, Lambda, isArrayLike, $mobx, isComputingDerivation as _isComputingDerivation, onReactionError, interceptReads as _interceptReads, IComputedValueOptions } from "./internal";
|
|
18
|
+
export { IObservable, IDepTreeNode, Reaction, IReactionPublic, IReactionDisposer, IDerivation, untracked, IDerivationState, IAtom, createAtom, IAction, spy, IComputedValue, IEqualsComparer, comparer, IEnhancer, IInterceptable, IInterceptor, IListenable, IObjectWillChange, IObjectDidChange, IObservableObject, isObservableObject, IValueDidChange, IValueWillChange, IObservableValue, isObservableValue as isBoxedObservable, IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice, isObservableArray, IKeyValueMap, ObservableMap, IMapEntries, IMapEntry, IMapWillChange, IMapDidChange, isObservableMap, IObservableMapInitialValues, ObservableSet, isObservableSet, ISetDidChange, ISetWillChange, IObservableSetInitialValues, transaction, observable, IObservableFactory, IObservableFactories, computed, IComputed, isObservable, isObservableProp, isComputed, isComputedProp, extendObservable, observe, intercept, autorun, IAutorunOptions, reaction, IReactionOptions, when, IWhenOptions, action, isAction, runInAction, IActionFactory, keys, values, entries, set, remove, has, get, decorate, configure, onBecomeObserved, onBecomeUnobserved, flow, toJS, trace, IObserverTree, IDependencyTree, getDependencyTree, getObserverTree, resetGlobalState as _resetGlobalState, getGlobalState as _getGlobalState, getDebugName, getAtom, getAdministration as _getAdministration, allowStateChanges as _allowStateChanges, allowStateChangesInsideComputed as _allowStateChangesInsideComputed, Lambda, isArrayLike, $mobx, isComputingDerivation as _isComputingDerivation, onReactionError, interceptReads as _interceptReads, IComputedValueOptions, IActionRunInfo, _startAction, _endAction } from "./internal";
|