-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: MobX 5 #1380
WIP: MobX 5 #1380
Changes from 170 commits
2f27d32
29c4e1f
ff6640a
ed05d20
5ea2505
c719720
c95ea23
424c006
dee8d24
b97dbd7
e935b52
32dfb0e
1090a2c
1bbcac3
ef9ffb9
1f04e8b
e8b230b
7bb3f14
b68df65
6d8c6af
6f7dc09
2dc4f1d
9d8a725
562030b
0d73fdd
94a8882
ea47438
6e50585
4b44c32
266764d
b2a4a9c
a78998a
e6363ad
25f2fed
18ad1d9
037020d
b7fec6e
5e230c2
aa2f558
f1c45e2
02c0994
5fb127c
84d4f0f
3e07bcb
7b7d6a7
c9bb570
1cd8e7b
8cccd93
67c1854
cf1eee2
d8ff405
8d63071
b96f623
a834549
eb13572
057df95
39710dc
c71ee1d
460ada2
052bc55
e9b497f
e2cc3b3
8562e77
1f88a64
8e13259
bee2ac3
5855bd3
b0fcdc1
647c3d5
a380e75
43779b8
f41dd51
a1a923b
7ae8796
5e2a24c
514802c
9ddc0ec
464d0aa
f49fcbc
102a2f1
6aee5e1
7179b96
e1de210
cff477c
a867c00
6f0bb9b
dbef2ab
09493ee
f6df576
2b00e62
3ae4444
394c418
b21b5e2
52d1541
8607ec3
b9ab050
d17e73c
dbe4c93
4ccf47c
8844da2
8cca76d
7d167ef
2654cc1
91c2ea4
10fca42
be5eb38
6b50a8c
b0ee838
88aa33b
37162c0
e9152bd
fab6f75
e61e8c9
8fb2861
45b4abc
6ec3907
d9d8ef4
b16b738
9fdfa8c
09feab1
e421854
ed0d15c
b0371bf
109eaf4
ac79559
524045d
10572e0
4b08f12
cf38655
a5f5793
d40b258
5a78e6d
20aab7c
79f33ee
e7e6e8d
fcc738f
d0184e1
098b0c9
d4f5302
1786bdc
6fcb5ae
5d2d9b0
2c3d4ee
75a07e4
cb61e2d
d631139
12b5c0e
62e006e
ac9d38f
eaab014
bfb0f63
a4b7354
047f168
b263c43
cdc8fd9
bb19bc1
778a587
7c96b62
ca1adb5
5a43e56
1ca32f5
e7f32aa
86b500d
4bc864d
3d35567
bfbe0c2
c572d10
a5dee3a
b1d8b97
e9d8760
e794a2c
7098bd2
841e586
68084ad
faf4bb8
de76c56
b54e03b
1be3976
495a45b
4f6ec32
1547199
b5e60e7
41c124b
e66b1ad
c405059
b3a43b3
37d6abc
445f7c0
a27b849
b05c2df
c53f8be
9aace8f
f695dae
405a025
e10dbda
5b8ba54
e17c478
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,94 @@ | ||
# 5.0.0 | ||
|
||
# Improvements | ||
|
||
* uses & requires proxies. otherwise use mobx 4 | ||
* observable objects created with `observable({...})` support dynamically adding keys | ||
- arrays are now spreadable and such | ||
|
||
# Breaking | ||
|
||
* The minimum runtime target is now ES2015, not ES5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idea: what about using preset-env with well defined and published browserlist, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not familiar with preset-env. How would that work / what does it do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mweststrate check https://github.com/tkrotoff/babel-preset-env-example and babel/website#1660 To sum up, babel-preset-env automagically only includes the polyfills and babel plugins needed for a given list of targeted browsers ( Edit: Babel 7 gives even more magic thx to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you also have granularity of last 2 major versions of edge, chrome, safari, and so |
||
* `spy` is a no-op in production builds | ||
* all deprecated api's are dropped. Make sure to not have any deprecation warnings before upgrading | ||
* dropped `array.move` and `array.peek` | ||
* dropped third arg to `array.find` and `array.findIndex` (not in standard) | ||
* `proxy: false` argument to `observable.object` to disable proxying (faster, but no dynamic key support) | ||
* `.$mobx` property has been dropped from all observables and replaced by a Symbol. Instead of e.g. `x.$mobx.name`, use `import { $mobx } from "mobx"; x[$mobx].name` | ||
* in some cases, the order in which autoruns are fired could have changed due to some internal optimizations (note that MobX never had a guarantee about the order in which autoruns fired!) | ||
|
||
Proxies | ||
- caveats: prebound methods `this` ain't the proxy! | ||
|
||
Caveat: Jest `toEqual` matcher might no longer play nicely with your class instances, due to a bug with the processing of symbols: https://github.com/facebook/jest/issues/6392. For now you might want to use a custom matcher if you are directly equalling observable objects. | ||
|
||
# 4.3.0 | ||
|
||
* Introduced the `entries(observable)` API, by @samjacobclift through [#1536](https://github.com/mobxjs/mobx/pull/1536) | ||
* Fixed [#1535](https://github.com/mobxjs/mobx/issues/1535): Change in nested computed value was not propagated if read outside action context when there is a pending reaction. For more details see the exact test case. | ||
* Illegal property access through prototypes is now a warning instead of an error. Fixes [#1506](https://github.com/mobxjs/mobx/issues/1506). By @AmazingTurtle through [#1529](https://github.com/mobxjs/mobx/pull/1529) | ||
* Fixed issue where providing a custom setter to `@computed({ set: ... })` wasn't picked up | ||
* Fixed #1545: Actions properties where not re-assignable when using TypeScript | ||
* Illegal Access checks are now a warning instead of an error. Fix | ||
|
||
# 4.2.1 | ||
|
||
* Fixed flow typings for `mobx.configure` [#1521](https://github.com/mobxjs/mobx/pull/1521) by @andrew--r | ||
* Improved typings for `mobx.flow`, fixes [#1527](https://github.com/mobxjs/mobx/issues/1527) | ||
* Throw error when using `@observable` in combination with a getter. [#1511](https://github.com/mobxjs/mobx/pull/1511) by @quanganhtran | ||
* `toJS` now uses Map internally, for faster detection of cycles. [#1517](https://github.com/mobxjs/mobx/pull/1517) by @loatheb | ||
* Fixed [#1512](https://github.com/mobxjs/mobx/issues/1512): `observe` hooks not being triggered when using `mobx.set`, Fixed in [#1514](https://github.com/mobxjs/mobx/pull/1514) by @quanganhtran | ||
* Several minor improvements, additional tests and doc improvements. | ||
|
||
# 4.2.0 | ||
|
||
* Introduced `configure({ enforceActions: "strict" })`, which is more strict then `enforceActions: true`, as it will also throw on non-observed changes to observables. See also [#1473](https://github.com/mobxjs/mobx/issues/1473) | ||
* Fixed [#1480](https://github.com/mobxjs/mobx/issues/1480): Exceptions in the effect handler of `reaction` where not properly picked up by the global reaction system | ||
* Fixed a bug where computed values updated their cached value, even when the comparer considered the new value equal to the previous one. Thanks @kuitos for finding this and fixing it! [#1499](https://github.com/mobxjs/mobx/pull/1499) | ||
* Undeprecated `ObservableMap`, fixes [#1496](https://github.com/mobxjs/mobx/issues/1496) | ||
* Observable arrays now support `Symbol.toStringTag` (if available / polyfilled). This allows libraries like Ramda to detect automatically that observable arrays are arrays. Fixes [#1490](https://github.com/mobxjs/mobx/issues/1490). Note that `Array.isArray` will keep returning false for the entire MobX 4 range. | ||
* Actions are now always `configurable` and `writable`, like in MobX 3. Fixes [#1477](https://github.com/mobxjs/mobx/issues/1477) | ||
* Merged several improvements to the flow typings. [#1501](https://github.com/mobxjs/mobx/pull/1501) by @quanganhtran | ||
* Fixed several accidental usages of the global `fail`, by @mtaran-google through [#1483](https://github.com/mobxjs/mobx/pull/1483) and [#1482](https://github.com/mobxjs/mobx/pull/1482) | ||
|
||
# 4.1.1 | ||
|
||
* Import `default` from MobX will no longer throw, but only warn instead. This fixes some issues with tools that reflect on the `default` export of a module. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line ends with a dot but other lines do not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
* Disposing a spy listener inside a spy handler no longer causes an exception. Fixes [#1459](https://github.com/mobxjs/mobx/issues/1459) through [#1460](https://github.com/mobxjs/mobx/pull/1460) by [farwayer](https://github.com/farwayer) | ||
* Added a missing `runInAction` overload in the flow typings. [#1451](https://github.com/mobxjs/mobx/pull/1451) by [AMilassin](https://github.com/mobxjs/mobx/issues?q=is%3Apr+author%3AAMilassin) | ||
* Improved the typings of `decorate`. See [#1450](https://github.com/mobxjs/mobx/pull/1450) by [makepost](https://github.com/mobxjs/mobx/issues?q=is%3Apr+author%3Amakepost) | ||
|
||
# 4.1.0 | ||
|
||
* Introduced `keepAlive` as option to `computed` | ||
* All observable api's now default to `any` for their generic arguments | ||
* Improved `flow` cancellation | ||
* The effect of `when` is now automatically an action. | ||
* `@computed` properties are now declared on their owner rather then the protoptype. Fixes an issue where `@computed` fields didn't work in React Native on proxied objects. See [#1396](https://github.com/mobxjs/mobx/issues/1396) | ||
* `action` and `action.bound` decorated fields are now reassignable, so that they can be stubbed | ||
|
||
# 4.0.2 | ||
|
||
* Fixed issue where exceptions like `TypeError: Cannot define property:__mobxDidRunLazyInitializers, object is not extensible.` were thrown. Fixes [#1404](https://github.com/mobxjs/mobx/issues/1404) | ||
* Improved flow typings for `flow`, [#1399](https://github.com/mobxjs/mobx/pull/1399) by @ismailhabib | ||
|
||
# 4.0.1 | ||
|
||
* Updated flow typings, see [#1393](https://github.com/mobxjs/mobx/pull/1393) by [andrew--r](https://github.com/andrew--r) | ||
|
||
# 4.0.0 | ||
|
||
* For the highlights of this release, read the [blog](https://medium.com/p/c1fbc08008da/): | ||
* For migration notes: see the [wiki page](https://github.com/mobxjs/mobx/wiki/Migrating-from-mobx-3-to-mobx-4) | ||
* Note; many things that were removed were removed to make the api surface smaller. If you thing some feature shouldn't have been removed, feel free to open an issue! | ||
* Note; many things that were removed to make the api surface smaller. If you think some feature shouldn't have been removed, feel free to open an issue! | ||
|
||
This is the extensive list of all changes. | ||
|
||
### New features | ||
|
||
The changes mentioned here are discussed in detail in the [release highlights](https://medium.com/p/c1fbc08008da/), or were simply updated in the docs. | ||
|
||
* MobX 4 introduces separation between the production and non production build. The production build strips most typechecks, resulting in a faster and smaller build. Make sure to substitute process.env.NODE_ENV = "production" in your build process! If you are using MobX in a react project, you most probably already have set this up. Otherwise, they idea is explained [here](https://reactjs.org/docs/add-react-to-an-existing-app.html). | ||
* MobX 4 introduces separation between the production and non production build. The production build strips most typechecks, resulting in a faster and smaller build. Make sure to substitute process.env.NODE_ENV = "production" in your build process! If you are using MobX in a react project, you most probably already have set this up. Otherwise, the idea is explained [here](https://reactjs.org/docs/add-react-to-an-existing-app.html). | ||
* Introduced `flow` to create a chain of async actions. This is the same function as [`asyncActions`](https://github.com/mobxjs/mobx-utils#asyncaction) of the mobx-utils package | ||
* These `flow`'s are now cancellable, by calling `.cancel()` on the returned promise, which will throw a cancellation exception into the generator function. | ||
* `flow` also has experimental support for async iterators (`async * function`) | ||
|
@@ -26,19 +104,19 @@ The changes mentioned here are discussed in detail in the [release highlights](h | |
* `computed(fn, options?)` / `@computed(options) get fn()` now accept the following options: | ||
* `set: (value) => void` to set a custom setter on the computed property | ||
* `name: "debug name"` | ||
* `equals: fn` the equality value to use for the computed to determine whether it's output has changed. The default is `comparer.default`. Alternatives are `comparer.structural`, `comparer.identity` or just your own comparison function. | ||
* `equals: fn` the equality value to use for the computed to determine whether its output has changed. The default is `comparer.default`. Alternatives are `comparer.structural`, `comparer.identity` or just your own comparison function. | ||
* `requiresReaction: boolean` see above. | ||
|
||
* `autorun(fn, options?)` now accepts the following options: | ||
* `delay: number` debounce the autorun with the given amount of milliseconds. This replaces the MobX 3 api `autorunAsync` | ||
* `name: "debug name" | ||
* `name: "debug name"` | ||
* `scheduler: function` a custom scheduler to run the autorun. For example to connect running the autorun to `requestAnimationFrame`. See the docs for more details | ||
* `onError`. A custom error handler to be notified when an autorun throws an exception. | ||
|
||
* `reaction(expr, effect, options?)` now accepts the following options: | ||
* `delay: number` debounce the autorun with the given amount of milliseconds. This replaces the MobX 3 api `autorunAsync` | ||
* `fireImmediately`. Immediately fire the effect function after the first evaluation of `expr` | ||
* `equals`. Custom equality function to determine whether the `expr` function differed from it's previous result, and hence should fire `effect`. Accepts the same options as the `equals` option of computed. | ||
* `equals`. Custom equality function to determine whether the `expr` function differed from its previous result, and hence should fire `effect`. Accepts the same options as the `equals` option of computed. | ||
* All the options `autorun` accepts | ||
|
||
* `when(predicate, effect?, options?)` now accepts the following options: | ||
|
@@ -66,7 +144,7 @@ The changes mentioned here are discussed in detail in the [release highlights](h | |
The changes mentioned here are discussed in detail in the [migration notes](https://github.com/mobxjs/mobx/wiki/Migrating-from-mobx-3-to-mobx-4) | ||
|
||
* MobX 4 requires `Map` to be globally available. Polyfill it if targeting IE < 11 or other older browsers. | ||
* For typescript users, MobX now requires `Map` and several `Symbol`s to exist for it's typings. So make sure that the `lib` configuration of your project is set to `"es6"`. (The compilation target can still be `"es5"`) | ||
* For typescript users, MobX now requires `Map` and several `Symbol`s to exist for its typings. So make sure that the `lib` configuration of your project is set to `"es6"`. (The compilation target can still be `"es5"`) | ||
* `observable.shallowArray(values)` has been removed, instead use `observable.array(values, { deep: false })` | ||
* `observable.shallowMap(values)` has been removed, instead use `observable.map(values, { deep: false })` | ||
* `observable.shallowObject(values)` has been removed, instead use `observable.object(values, {}, { deep: false })` | ||
|
@@ -613,6 +691,18 @@ observable({ | |
}) | ||
``` | ||
|
||
By the way, if you have code such as: | ||
|
||
``` | ||
observable({ | ||
@computed get someProp() { ... } | ||
}); | ||
``` | ||
|
||
That code will no longer work. Rather, reactions will fail silently. Remove `@computed`. | ||
Note, this only applies when using observable in this way; it doesn't apply when using | ||
`@observable` on a property within a class declaration. | ||
|
||
### Misc | ||
|
||
* Fixed #701: `toJS` sometimes failing to convert objects decorated with `@observable` (cause: `isObservable` sometimes returned false on these object) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated