mobx 5.7.0 → 5.9.4
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 +46 -0
- package/LICENSE +0 -0
- package/README.md +27 -17
- package/lib/api/action.d.ts +1 -1
- package/lib/api/actiondecorator.d.ts +12 -1
- package/lib/api/become-observed.d.ts +3 -3
- package/lib/api/computed.d.ts +1 -1
- package/lib/api/flow.d.ts +8 -13
- package/lib/api/intercept-read.d.ts +2 -1
- package/lib/api/intercept.d.ts +2 -1
- package/lib/api/object-api.d.ts +6 -1
- package/lib/api/observable.d.ts +3 -1
- package/lib/api/observe.d.ts +2 -1
- package/lib/core/action.d.ts +1 -1
- package/lib/core/atom.d.ts +4 -1
- package/lib/core/computedvalue.d.ts +3 -1
- package/lib/core/globalstate.d.ts +1 -0
- package/lib/core/observable.d.ts +3 -1
- package/lib/internal.d.ts +1 -0
- package/lib/mobx.d.ts +1 -1
- package/lib/mobx.es6.js +358 -60
- package/lib/mobx.js +392 -57
- package/lib/mobx.js.flow +2 -2
- package/lib/mobx.min.js +1 -1
- package/lib/mobx.min.js.map +1 -1
- package/lib/mobx.module.js +391 -58
- package/lib/mobx.umd.js +392 -57
- package/lib/mobx.umd.min.js +1 -1
- package/lib/mobx.umd.min.js.map +1 -1
- package/lib/types/observablemap.d.ts +1 -1
- package/lib/types/observableset.d.ts +49 -0
- package/lib/types/observablevalue.d.ts +5 -3
- package/lib/utils/utils.d.ts +1 -0
- package/package.json +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
# 5.9.4 / 4.9.4
|
|
2
|
+
|
|
3
|
+
* Allow symbol keys in `ObservableMap`, see [#1930](https://github.com/mobxjs/mobx/pull/1930) by [pimterry](https://github.com/pimterry)
|
|
4
|
+
* Fixed type definitions of `toStringTag` for Maps and Sets, see [#1929](https://github.com/mobxjs/mobx/pull/1929) by [lennerd](https://github.com/mobxjs/mobx/pull/1929)
|
|
5
|
+
|
|
6
|
+
# 4.9.3
|
|
7
|
+
|
|
8
|
+
* Fixed `observable.set` compatibility with IE 11, see [#1917](https://github.com/mobxjs/mobx/pull/1917) by [kalmi](https://github.com/kalmi)
|
|
9
|
+
|
|
10
|
+
# 4.9.2
|
|
11
|
+
|
|
12
|
+
* Fixed regression [#1878](https://github.com/mobxjs/mobx/issues/1878), accidental use of `Symbol` breaking Internet Explorer / React Native compatibility.
|
|
13
|
+
|
|
14
|
+
# 4.9.1
|
|
15
|
+
|
|
16
|
+
* Fixed regression in `toJS`: observable maps were not properly serialized. Fixes [#1875](https://github.com/mobxjs/mobx/issues/1875)
|
|
17
|
+
|
|
18
|
+
# 5.9.0 / 4.9.0
|
|
19
|
+
|
|
20
|
+
**Features**
|
|
21
|
+
|
|
22
|
+
* Introduced support for observable sets! Through [#1592](https://github.com/mobxjs/mobx/pull/1592) by [@newraina](https://github.com/newraina)
|
|
23
|
+
* `observable.box` now accepts an `equals` option, to be able to pass a custom comparision function. Through [#1862](https://github.com/mobxjs/mobx/pull/1862), [#1874](https://github.com/mobxjs/mobx/pull/1874) by [@fi3ework](https://github.com/fi3ework). Fixes [#1580](https://github.com/mobxjs/mobx/issues/1580)
|
|
24
|
+
* Improved logging of reactions; if an action throws an exception, errors in reactions that react to that are only logged as warnings. Fixes [#1836](https://github.com/mobxjs/mobx/issues/1836)
|
|
25
|
+
|
|
26
|
+
**Fixes**
|
|
27
|
+
|
|
28
|
+
* Improved typings for `flow`, see [#1827](https://github.com/mobxjs/mobx/pull/1827) by [@xaviergonz](https://github.com/xaviergonz)
|
|
29
|
+
* Don't allow subclassing map, fixes [#1858](https://github.com/mobxjs/mobx/issues/1858)
|
|
30
|
+
* Fixed `trace(true)` not being able to handle multi-line comments in traced function. Fixes [#1850](https://github.com/mobxjs/mobx/issues/1850)
|
|
31
|
+
* `@computed` now introduces non-configurable properties, to fail fast on incorrect inheritance or property deletion. Fixes [#1867](https://github.com/mobxjs/mobx/issues/1867)
|
|
32
|
+
* The options `enforceActions` and `isolateGlobalState` now work correctly when used together. Fixes [#1869](https://github.com/mobxjs/mobx/issues/1869)
|
|
33
|
+
|
|
34
|
+
# 5.8.0 / 4.8.0
|
|
35
|
+
|
|
36
|
+
* MobX now requires TypeScript 3 (this was already the case in 5.7.0, but in this version the difference is actually noticeable in the typings).
|
|
37
|
+
* Fixed array dehancer sometimes skipping. Fixes [#1839](https://github.com/mobxjs/mobx/issues/1839) through [#1841](https://github.com/mobxjs/mobx/pull/1841) by [k-g-a](https://github.com/k-g-a)
|
|
38
|
+
* Fixed issue where webpack 4 wouldn't use the ESM module [#1834](https://github.com/mobxjs/mobx/pull/1834) by [mrtnbroder](https://github.com/mrtnbroder)
|
|
39
|
+
* Improved type inference for `flow` in TypeScript 3. Fixes [#1816](https://github.com/mobxjs/mobx/issue/1816) through [#1825](https://github.com/mobxjs/mobx/pull/1825) by [ismailhabib](https://github.com/ismailhabib)
|
|
40
|
+
* Introduced support for global environment variable `IGNORE_MOBX_MINIFIY_WARNING=true` to skip the built-in minification warning. See [#1835](https://github.com/mobxjs/mobx/pull/1835) by [fi3ework](https://github.com/fi3ework)
|
|
41
|
+
* Fixed onBecome(Un)Observed dispoer cleanup. Fixes [#1537](https://github.com/mobxjs/mobx/issues/1537) through [#1833](https://github.com/mobxjs/mobx/pull/1833) by [fi3ework](https://github.com/fi3ework)
|
|
42
|
+
|
|
43
|
+
# 5.7.1 / 4.7.1
|
|
44
|
+
* Fixed [#1839](https://github.com/mobxjs/mobx/issues/1839), ObservableArrayAdministration.dehanceValues does not dehance last value.
|
|
45
|
+
|
|
1
46
|
# 5.7.0 / 4.7.0
|
|
2
47
|
|
|
3
48
|
* Upgraded typings to TypeScript 3
|
|
@@ -122,6 +167,7 @@ _Note June 7th, 2018:_ Both issues are already in Jest master and should be rele
|
|
|
122
167
|
* Don't `slice()` arrays when passing them to external libraries. (Note you still shouldn't pass observable data structures to non-`observer` React components, which is an orthogonal concept)
|
|
123
168
|
* You could replace observable maps with observable objects if you are only using string-based keys.
|
|
124
169
|
* Don't call the `reverse` or `sort` operations directly on observableArray's anymore, as it's behavior slightly differed from the built-in implementations of those methods. Instead use `observableArray.slice().sort()` to perform the sort on a copy. This gives no additional performance overhead compared to MobX 4. (The reason behind this is that built-in `sort` updates the array in place, but the observable array implementation always performed the sort on a defensive copy, and this change makes that explicit).
|
|
170
|
+
* you may remove usages of `isArrayLike()` since `Array.isArray()` will now return true for observable arrays
|
|
125
171
|
|
|
126
172
|
|
|
127
173
|
### API's that have been dropped
|
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -12,12 +12,18 @@ _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 and many [individual
|
|
16
|
-
|
|
17
|
-
<
|
|
18
|
-
<img src="docs/
|
|
19
|
-
<img src="docs/
|
|
20
|
-
<img src="docs/
|
|
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
|
+
|
|
17
|
+
<a href="https://mendix.com/"><img src="docs/mendix-logo.png" align="center" width="100" title="Mendix" alt="Mendix" /></a>
|
|
18
|
+
<a href="https://coinbase.com/"><img src="docs/coinbase.jpeg" align="center" width="100" title="Coinbase" alt="Coinbase" /></a>
|
|
19
|
+
<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
|
+
<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
|
+
<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
|
+
<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
|
+
<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>
|
|
21
27
|
|
|
22
28
|
# Installation
|
|
23
29
|
|
|
@@ -33,11 +39,11 @@ _Tip: Consider using the faster and smaller ES6 build if targetting a modern env
|
|
|
33
39
|
|
|
34
40
|
| MobX version | Actively supported | Supported browsers | GitHub branch |
|
|
35
41
|
| ----- | ----- | --- | --- |
|
|
36
|
-
| 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` |
|
|
42
|
+
| 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, Google's crawler bot | `master` |
|
|
37
43
|
| 4.* | Yes (LTS) | Any ES5 compliant browser | `mobx4-master` |
|
|
38
44
|
| 1-3.* | No | Any ES5 compliant browser | No active branch |
|
|
39
45
|
|
|
40
|
-
* MobX >=5 runs on any browser with [ES6 proxy support](https://kangax.github.io/compat-table/es6/#test-Proxy). It will throw an error on startup on older environments such as IE11, Node.js <6 or React Native Android on old JavaScriptCore [how-to-upgrade](https://github.com/react-community/jsc-android-buildscripts#how-to-use-it-with-my-react-native-app). _Warning: since upgrading JSC is non-trivial, and decorators can be [troublesome](https://github.com/mobxjs/mobx/issues/1777) as well in React Native, for now it is recommended to stick to MobX 4.x for
|
|
46
|
+
* MobX >=5 runs on any browser with [ES6 proxy support](https://kangax.github.io/compat-table/es6/#test-Proxy). It will throw an error on startup on older environments such as IE11, Node.js <6 or React Native Android on old JavaScriptCore [how-to-upgrade](https://github.com/react-community/jsc-android-buildscripts#how-to-use-it-with-my-react-native-app). _Warning: since upgrading JSC is non-trivial, and decorators can be [troublesome](https://github.com/mobxjs/mobx/issues/1777) as well in React Native, for now it is recommended to stick to MobX 4.x for React Native Android development_.
|
|
41
47
|
* 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).
|
|
42
48
|
|
|
43
49
|
|
|
@@ -88,11 +94,11 @@ MobX adds observable capabilities to existing data structures like objects, arra
|
|
|
88
94
|
This can simply be done by annotating your class properties with the [@observable](http://mobxjs.github.io/mobx/refguide/observable-decorator.html) decorator (ES.Next).
|
|
89
95
|
|
|
90
96
|
```javascript
|
|
91
|
-
import { observable } from
|
|
97
|
+
import { observable } from 'mobx';
|
|
92
98
|
|
|
93
99
|
class Todo {
|
|
94
100
|
id = Math.random();
|
|
95
|
-
@observable title =
|
|
101
|
+
@observable title = '';
|
|
96
102
|
@observable finished = false;
|
|
97
103
|
}
|
|
98
104
|
```
|
|
@@ -106,11 +112,11 @@ Or you can skip them altoghether, as MobX can be used fine without decorator _sy
|
|
|
106
112
|
Many MobX users prefer the slightly more concise decorator syntax, but the following snippet achieves the same:
|
|
107
113
|
|
|
108
114
|
```javascript
|
|
109
|
-
import { decorate, observable } from
|
|
115
|
+
import { decorate, observable } from 'mobx';
|
|
110
116
|
|
|
111
117
|
class Todo {
|
|
112
118
|
id = Math.random();
|
|
113
|
-
title =
|
|
119
|
+
title = '';
|
|
114
120
|
finished = false;
|
|
115
121
|
}
|
|
116
122
|
decorate(Todo, {
|
|
@@ -173,7 +179,7 @@ class TodoListView extends Component {
|
|
|
173
179
|
const TodoView = observer(({todo}) =>
|
|
174
180
|
<li>
|
|
175
181
|
<input
|
|
176
|
-
type=
|
|
182
|
+
type='checkbox'
|
|
177
183
|
checked={todo.finished}
|
|
178
184
|
onClick={() => todo.finished = !todo.finished}
|
|
179
185
|
/>{todo.title}
|
|
@@ -197,7 +203,7 @@ For example the following `autorun` prints a log message each time the amount of
|
|
|
197
203
|
|
|
198
204
|
```javascript
|
|
199
205
|
autorun(() => {
|
|
200
|
-
console.log(
|
|
206
|
+
console.log(`Tasks left: ${ todos.unfinishedTodoCount }`)
|
|
201
207
|
})
|
|
202
208
|
```
|
|
203
209
|
|
|
@@ -227,8 +233,8 @@ There is no technical need for firing events, calling a dispatcher, etc. A React
|
|
|
227
233
|
|
|
228
234
|
```javascript
|
|
229
235
|
store.todos.push(
|
|
230
|
-
new Todo(
|
|
231
|
-
new Todo(
|
|
236
|
+
new Todo('Get Coffee'),
|
|
237
|
+
new Todo('Write simpler code')
|
|
232
238
|
);
|
|
233
239
|
store.todos[0].finished = true;
|
|
234
240
|
```
|
|
@@ -311,10 +317,14 @@ And finally, kudos to all the people that believed in, tried, validated and even
|
|
|
311
317
|
|
|
312
318
|
> The #mobx is the way I always want things to be! It's really surprising simple and fast! Totally awesome! Don't miss it!
|
|
313
319
|
|
|
320
|
+
> I've been using MobX for over 2 years now, and it *still* feels like cheating! 😎
|
|
321
|
+
|
|
314
322
|
## Contributing
|
|
315
323
|
|
|
316
324
|
* Feel free to send small pull requests. Please discuss new features or big changes in a GitHub issue first.
|
|
317
|
-
* Use `
|
|
325
|
+
* Use `yarn test` to run the basic test suite.
|
|
326
|
+
* Use `yarn test:travis` for the test suite with coverage.
|
|
327
|
+
* and `yarn test:performance` for the performance tests.
|
|
318
328
|
* 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.
|
|
319
329
|
|
|
320
330
|
# MobX 4 vs MobX 5
|
package/lib/api/action.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface IActionFactory {
|
|
|
18
18
|
(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): void;
|
|
19
19
|
bound(target: Object, propertyKey: string | symbol, descriptor?: PropertyDescriptor): void;
|
|
20
20
|
}
|
|
21
|
-
export declare
|
|
21
|
+
export declare const action: IActionFactory;
|
|
22
22
|
export declare function runInAction<T>(block: () => T): T;
|
|
23
23
|
export declare function runInAction<T>(name: string, block: () => T): T;
|
|
24
24
|
export declare function isAction(thing: any): boolean;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { BabelDescriptor } from "../internal";
|
|
2
2
|
declare function dontReassignFields(): void;
|
|
3
|
-
export declare function namedActionDecorator(name: string): (target: any, prop: any, descriptor: BabelDescriptor) =>
|
|
3
|
+
export declare function namedActionDecorator(name: string): (target: any, prop: any, descriptor: BabelDescriptor) => void | {
|
|
4
|
+
value: Function & import("../internal").IAction;
|
|
5
|
+
enumerable: boolean;
|
|
6
|
+
configurable: boolean;
|
|
7
|
+
writable: boolean;
|
|
8
|
+
} | {
|
|
9
|
+
enumerable: boolean;
|
|
10
|
+
configurable: boolean;
|
|
11
|
+
writable: boolean;
|
|
12
|
+
initializer(): Function & import("../internal").IAction;
|
|
13
|
+
value?: undefined;
|
|
14
|
+
};
|
|
4
15
|
export declare function actionFieldDecorator(name: string): (target: any, prop: any, descriptor: any) => void;
|
|
5
16
|
export declare function boundActionDecorator(target: any, propertyName: any, descriptor: any, applyToInstance?: boolean): {
|
|
6
17
|
configurable: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IComputedValue, IObservable, IObservableArray, Lambda, ObservableMap } from "../internal";
|
|
2
|
-
export declare function onBecomeObserved(value: IObservable | IComputedValue<any> | IObservableArray<any> | ObservableMap<any, any>, listener: Lambda): Lambda;
|
|
1
|
+
import { IComputedValue, IObservable, IObservableArray, Lambda, ObservableMap, ObservableSet } from "../internal";
|
|
2
|
+
export declare function onBecomeObserved(value: IObservable | IComputedValue<any> | IObservableArray<any> | ObservableMap<any, any> | ObservableSet<any>, listener: Lambda): Lambda;
|
|
3
3
|
export declare function onBecomeObserved<K, V = any>(value: ObservableMap<K, V> | Object, property: K, listener: Lambda): Lambda;
|
|
4
|
-
export declare function onBecomeUnobserved(value: IObservable | IComputedValue<any> | IObservableArray<any> | ObservableMap<any, any>, listener: Lambda): Lambda;
|
|
4
|
+
export declare function onBecomeUnobserved(value: IObservable | IComputedValue<any> | IObservableArray<any> | ObservableMap<any, any> | ObservableSet<any>, listener: Lambda): Lambda;
|
|
5
5
|
export declare function onBecomeUnobserved<K, V = any>(value: ObservableMap<K, V> | Object, property: K, listener: Lambda): Lambda;
|
package/lib/api/computed.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export declare const computedDecorator: Function;
|
|
|
11
11
|
* Decorator for class properties: @computed get value() { return expr; }.
|
|
12
12
|
* For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
|
|
13
13
|
*/
|
|
14
|
-
export declare
|
|
14
|
+
export declare const computed: IComputed;
|
package/lib/api/flow.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
export declare type CancellablePromise<T> = Promise<T> & {
|
|
2
2
|
cancel(): void;
|
|
3
3
|
};
|
|
4
|
-
export interface
|
|
5
|
-
|
|
6
|
-
return?(value?: any): IteratorResult<T> | Promise<IteratorResult<T>>;
|
|
7
|
-
throw?(e?: any): IteratorResult<T> | Promise<IteratorResult<T>>;
|
|
4
|
+
export interface FlowYield {
|
|
5
|
+
"!!flowYield": undefined;
|
|
8
6
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare
|
|
13
|
-
export declare
|
|
14
|
-
export declare function flow<
|
|
15
|
-
export declare function flow<A1, A2, A3, A4, A5, A6>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => FlowIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => CancellablePromise<any>;
|
|
16
|
-
export declare function flow<A1, A2, A3, A4, A5, A6, A7>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => FlowIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => CancellablePromise<any>;
|
|
17
|
-
export declare function flow<A1, A2, A3, A4, A5, A6, A7, A8>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => FlowIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => CancellablePromise<any>;
|
|
7
|
+
export interface FlowReturn<T> {
|
|
8
|
+
"!!flowReturn": T;
|
|
9
|
+
}
|
|
10
|
+
export declare type FlowReturnType<R> = IfAllAreFlowYieldThenVoid<R extends FlowReturn<infer FR> ? FR extends Promise<infer FRP> ? FRP : FR : R extends Promise<any> ? FlowYield : R>;
|
|
11
|
+
export declare type IfAllAreFlowYieldThenVoid<R> = Exclude<R, FlowYield> extends never ? void : Exclude<R, FlowYield>;
|
|
12
|
+
export declare function flow<R, Args extends any[]>(generator: (...args: Args) => IterableIterator<R>): (...args: Args) => CancellablePromise<FlowReturnType<R>>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { IObservableArray, IObservableValue, Lambda, ObservableMap } from "../internal";
|
|
1
|
+
import { IObservableArray, IObservableValue, Lambda, ObservableMap, ObservableSet } from "../internal";
|
|
2
2
|
export declare type ReadInterceptor<T> = (value: any) => T;
|
|
3
3
|
/** Experimental feature right now, tested indirectly via Mobx-State-Tree */
|
|
4
4
|
export declare function interceptReads<T>(value: IObservableValue<T>, handler: ReadInterceptor<T>): Lambda;
|
|
5
5
|
export declare function interceptReads<T>(observableArray: IObservableArray<T>, handler: ReadInterceptor<T>): Lambda;
|
|
6
6
|
export declare function interceptReads<K, V>(observableMap: ObservableMap<K, V>, handler: ReadInterceptor<V>): Lambda;
|
|
7
|
+
export declare function interceptReads<V>(observableSet: ObservableSet<V>, handler: ReadInterceptor<V>): Lambda;
|
|
7
8
|
export declare function interceptReads(object: Object, property: string, handler: ReadInterceptor<any>): Lambda;
|
package/lib/api/intercept.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { IArrayWillChange, IArrayWillSplice, IInterceptor, IMapWillChange, IObjectWillChange, IObservableArray, IObservableValue, IValueWillChange, Lambda, ObservableMap } from "../internal";
|
|
1
|
+
import { IArrayWillChange, IArrayWillSplice, IInterceptor, IMapWillChange, IObjectWillChange, IObservableArray, IObservableValue, IValueWillChange, Lambda, ObservableMap, ObservableSet, ISetWillChange } from "../internal";
|
|
2
2
|
export declare function intercept<T>(value: IObservableValue<T>, handler: IInterceptor<IValueWillChange<T>>): Lambda;
|
|
3
3
|
export declare function intercept<T>(observableArray: IObservableArray<T>, handler: IInterceptor<IArrayWillChange<T> | IArrayWillSplice<T>>): Lambda;
|
|
4
4
|
export declare function intercept<K, V>(observableMap: ObservableMap<K, V>, handler: IInterceptor<IMapWillChange<K, V>>): Lambda;
|
|
5
|
+
export declare function intercept<V>(observableMap: ObservableSet<V>, handler: IInterceptor<ISetWillChange<V>>): Lambda;
|
|
5
6
|
export declare function intercept<K, V>(observableMap: ObservableMap<K, V>, property: K, handler: IInterceptor<IValueWillChange<V>>): Lambda;
|
|
6
7
|
export declare function intercept(object: Object, handler: IInterceptor<IObjectWillChange>): Lambda;
|
|
7
8
|
export declare function intercept<T extends Object, K extends keyof T>(object: T, property: K, handler: IInterceptor<IValueWillChange<any>>): Lambda;
|
package/lib/api/object-api.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { IObservableArray, ObservableMap } from "../internal";
|
|
1
|
+
import { IObservableArray, ObservableMap, ObservableSet } from "../internal";
|
|
2
2
|
export declare function keys<K>(map: ObservableMap<K, any>): ReadonlyArray<K>;
|
|
3
3
|
export declare function keys<T>(ar: IObservableArray<T>): ReadonlyArray<number>;
|
|
4
|
+
export declare function keys<T>(set: ObservableSet<T>): ReadonlyArray<T>;
|
|
4
5
|
export declare function keys<T extends Object>(obj: T): ReadonlyArray<string>;
|
|
5
6
|
export declare function values<K, T>(map: ObservableMap<K, T>): ReadonlyArray<T>;
|
|
7
|
+
export declare function values<T>(set: ObservableSet<T>): ReadonlyArray<T>;
|
|
6
8
|
export declare function values<T>(ar: IObservableArray<T>): ReadonlyArray<T>;
|
|
7
9
|
export declare function values<T = any>(obj: T): ReadonlyArray<any>;
|
|
8
10
|
export declare function entries<K, T>(map: ObservableMap<K, T>): ReadonlyArray<[K, T]>;
|
|
11
|
+
export declare function entries<T>(set: ObservableSet<T>): ReadonlyArray<[T, T]>;
|
|
9
12
|
export declare function entries<T>(ar: IObservableArray<T>): ReadonlyArray<[number, T]>;
|
|
10
13
|
export declare function entries<T = any>(obj: T): ReadonlyArray<[string, any]>;
|
|
11
14
|
export declare function set<V>(obj: ObservableMap<string, V>, values: {
|
|
@@ -18,9 +21,11 @@ export declare function set<T extends Object>(obj: T, values: {
|
|
|
18
21
|
}): any;
|
|
19
22
|
export declare function set<T extends Object>(obj: T, key: string, value: any): any;
|
|
20
23
|
export declare function remove<K, V>(obj: ObservableMap<K, V>, key: K): any;
|
|
24
|
+
export declare function remove<T>(obj: ObservableSet<T>, key: T): any;
|
|
21
25
|
export declare function remove<T>(obj: IObservableArray<T>, index: number): any;
|
|
22
26
|
export declare function remove<T extends Object>(obj: T, key: string): any;
|
|
23
27
|
export declare function has<K>(obj: ObservableMap<K, any>, key: K): boolean;
|
|
28
|
+
export declare function has<T>(obj: ObservableSet<T>, key: T): boolean;
|
|
24
29
|
export declare function has<T>(obj: IObservableArray<T>, index: number): boolean;
|
|
25
30
|
export declare function has<T extends Object>(obj: T, key: string): boolean;
|
|
26
31
|
export declare function get<K, V>(obj: ObservableMap<K, V>, key: K): V | undefined;
|
package/lib/api/observable.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IEnhancer, IObservableArray, IObservableDecorator, IObservableMapInitialValues, IObservableObject, IObservableValue, ObservableMap } from "../internal";
|
|
1
|
+
import { IEnhancer, IEqualsComparer, IObservableArray, IObservableDecorator, IObservableMapInitialValues, IObservableSetInitialValues, IObservableObject, IObservableValue, ObservableMap, ObservableSet } from "../internal";
|
|
2
2
|
export declare type CreateObservableOptions = {
|
|
3
3
|
name?: string;
|
|
4
|
+
equals?: IEqualsComparer<any>;
|
|
4
5
|
deep?: boolean;
|
|
5
6
|
defaultDecorator?: IObservableDecorator;
|
|
6
7
|
proxy?: boolean;
|
|
@@ -21,6 +22,7 @@ export interface IObservableFactory {
|
|
|
21
22
|
export interface IObservableFactories {
|
|
22
23
|
box<T = any>(value?: T, options?: CreateObservableOptions): IObservableValue<T>;
|
|
23
24
|
array<T = any>(initialValues?: T[], options?: CreateObservableOptions): IObservableArray<T>;
|
|
25
|
+
set<T = any>(initialValues?: IObservableSetInitialValues<T>, options?: CreateObservableOptions): ObservableSet<T>;
|
|
24
26
|
map<K = any, V = any>(initialValues?: IObservableMapInitialValues<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
|
|
25
27
|
object<T = any>(props: T, decorators?: {
|
|
26
28
|
[K in keyof T]?: Function;
|
package/lib/api/observe.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IArrayChange, IArraySplice, IComputedValue, IMapDidChange, IObjectDidChange, IObservableArray, IObservableValue, IValueDidChange, Lambda, ObservableMap } from "../internal";
|
|
1
|
+
import { IArrayChange, IArraySplice, IComputedValue, IMapDidChange, IObjectDidChange, IObservableArray, IObservableValue, IValueDidChange, Lambda, ObservableMap, ObservableSet, ISetDidChange } from "../internal";
|
|
2
2
|
export declare function observe<T>(value: IObservableValue<T> | IComputedValue<T>, listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean): Lambda;
|
|
3
3
|
export declare function observe<T>(observableArray: IObservableArray<T>, listener: (change: IArrayChange<T> | IArraySplice<T>) => void, fireImmediately?: boolean): Lambda;
|
|
4
|
+
export declare function observe<V>(observableMap: ObservableSet<V>, listener: (change: ISetDidChange<V>) => void, fireImmediately?: boolean): Lambda;
|
|
4
5
|
export declare function observe<K, V>(observableMap: ObservableMap<K, V>, listener: (change: IMapDidChange<K, V>) => void, fireImmediately?: boolean): Lambda;
|
|
5
6
|
export declare function observe<K, V>(observableMap: ObservableMap<K, V>, property: K, listener: (change: IValueDidChange<V>) => void, fireImmediately?: boolean): Lambda;
|
|
6
7
|
export declare function observe(object: Object, listener: (change: IObjectDidChange) => void, fireImmediately?: boolean): Lambda;
|
package/lib/core/action.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface IAction {
|
|
2
2
|
isMobxAction: boolean;
|
|
3
3
|
}
|
|
4
|
-
export declare function createAction(actionName: string, fn: Function): Function & IAction;
|
|
4
|
+
export declare function createAction(actionName: string, fn: Function, ref?: Object): Function & IAction;
|
|
5
5
|
export declare function executeAction(actionName: string, fn: Function, scope?: any, args?: IArguments): any;
|
|
6
6
|
export declare function allowStateChanges<T>(allowStateChanges: boolean, func: () => T): T;
|
|
7
7
|
export declare function allowStateChangesStart(allowStateChanges: boolean): boolean;
|
package/lib/core/atom.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IDerivationState, IObservable } from "../internal";
|
|
2
|
+
import { Lambda } from "../utils/utils";
|
|
2
3
|
export declare const $mobx: unique symbol;
|
|
3
4
|
export interface IAtom extends IObservable {
|
|
4
5
|
reportObserved(): any;
|
|
@@ -17,8 +18,10 @@ export declare class Atom implements IAtom {
|
|
|
17
18
|
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
18
19
|
*/
|
|
19
20
|
constructor(name?: string);
|
|
20
|
-
|
|
21
|
+
onBecomeObservedListeners: Set<Lambda> | undefined;
|
|
22
|
+
onBecomeUnobservedListeners: Set<Lambda> | undefined;
|
|
21
23
|
onBecomeObserved(): void;
|
|
24
|
+
onBecomeUnobserved(): void;
|
|
22
25
|
/**
|
|
23
26
|
* Invoke this method to notify mobx that your atom has been used somehow.
|
|
24
27
|
* Returns true if there is currently a reactive context.
|
|
@@ -71,8 +71,10 @@ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>,
|
|
|
71
71
|
*/
|
|
72
72
|
constructor(options: IComputedValueOptions<T>);
|
|
73
73
|
onBecomeStale(): void;
|
|
74
|
-
|
|
74
|
+
onBecomeObservedListeners: Set<Lambda> | undefined;
|
|
75
|
+
onBecomeUnobservedListeners: Set<Lambda> | undefined;
|
|
75
76
|
onBecomeObserved(): void;
|
|
77
|
+
onBecomeUnobserved(): void;
|
|
76
78
|
/**
|
|
77
79
|
* Returns the current value of this computed value.
|
|
78
80
|
* Will evaluate its computation first if needed.
|
package/lib/core/observable.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDerivation, IDerivationState } from "../internal";
|
|
1
|
+
import { Lambda, IDerivation, IDerivationState } from "../internal";
|
|
2
2
|
export interface IDepTreeNode {
|
|
3
3
|
name: string;
|
|
4
4
|
observing?: IObservable[];
|
|
@@ -17,6 +17,8 @@ export interface IObservable extends IDepTreeNode {
|
|
|
17
17
|
observers: Set<IDerivation>;
|
|
18
18
|
onBecomeUnobserved(): void;
|
|
19
19
|
onBecomeObserved(): void;
|
|
20
|
+
onBecomeUnobservedListeners: Set<Lambda> | undefined;
|
|
21
|
+
onBecomeObservedListeners: Set<Lambda> | undefined;
|
|
20
22
|
}
|
|
21
23
|
export declare function hasObservers(observable: IObservable): boolean;
|
|
22
24
|
export declare function getObservers(observable: IObservable): Set<IDerivation>;
|
package/lib/internal.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export * from "./types/intercept-utils";
|
|
|
38
38
|
export * from "./types/listen-utils";
|
|
39
39
|
export * from "./types/observablearray";
|
|
40
40
|
export * from "./types/observablemap";
|
|
41
|
+
export * from "./types/observableset";
|
|
41
42
|
export * from "./types/observableobject";
|
|
42
43
|
export * from "./types/type-utils";
|
|
43
44
|
export * from "./utils/eq";
|
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, 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 } from "./internal";
|