mobx 3.2.2 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +2 -1
- package/lib/api/expr.d.ts +13 -13
- package/lib/api/intercept-read.d.ts +4 -4
- package/lib/api/intercept.d.ts +1 -1
- package/lib/api/isobservable.d.ts +4 -4
- package/lib/api/tojs.d.ts +2 -2
- package/lib/core/computedvalue.d.ts +3 -1
- package/lib/mobx.d.ts +1 -1
- package/lib/mobx.js +324 -211
- package/lib/mobx.js.flow +487 -549
- package/lib/mobx.min.js +2 -2
- package/lib/mobx.min.js.map +1 -1
- package/lib/mobx.module.js +324 -211
- package/lib/mobx.umd.js +324 -211
- package/lib/mobx.umd.min.js +2 -2
- package/lib/mobx.umd.min.js.map +1 -1
- package/lib/types/observableobject.d.ts +4 -4
- package/package.json +15 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# 3.3.0
|
|
2
|
+
|
|
3
|
+
* Undeprecated `transaction`, see [#1139](https://github.com/mobxjs/mobx/issues/1139)
|
|
4
|
+
* Fixed typings of reaction [#1136](https://github.com/mobxjs/mobx/issues/1136)
|
|
5
|
+
* It is now possible to re-define a computed property [#1121](https://github.com/mobxjs/mobx/issues/1121)
|
|
6
|
+
* Print an helpful error message when using `@action` on a getter [#971](https://github.com/mobxjs/mobx/issues/971)
|
|
7
|
+
* Improved typings of intercept [#1119](https://github.com/mobxjs/mobx/issues/1119)
|
|
8
|
+
* Made code base Prettier [#1103](https://github.com/mobxjs/mobx/issues/1103)
|
|
9
|
+
* react-native will now by default use the es module build as well.
|
|
10
|
+
* Added support for Weex, see [#1163](https://github.com/mobxjs/mobx/pull/1163/)
|
|
11
|
+
* Added workaround for Firefox issue causing MobX to crash, see [#614](https://github.com/mobxjs/mobx/issues/614)
|
|
12
|
+
|
|
1
13
|
# 3.2.2
|
|
2
14
|
|
|
3
15
|
* Fixes a bug (or a known limitation) described in [#1092](https://github.com/mobxjs/mobx/issue/1092/). It is now possible to have different observable administration on different levels of the prototype chain. By @guillaumeleclerc
|
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ _Simple, scalable state management_
|
|
|
11
11
|
[](https://mobxjs.github.io/mobx/donate.html)
|
|
12
12
|
[](#backers)
|
|
13
13
|
[](#sponsors)
|
|
14
|
+
[](https://github.com/prettier/prettier)
|
|
14
15
|
|
|
15
16
|

|
|
16
17
|
|
|
@@ -55,7 +56,7 @@ Both React and MobX provide very optimal and unique solutions to common problems
|
|
|
55
56
|
|
|
56
57
|
## Core concepts
|
|
57
58
|
|
|
58
|
-
MobX has only a few core concepts. The following snippets can be tried online using [JSFiddle](https://jsfiddle.net/mweststrate/
|
|
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/)).
|
|
59
60
|
|
|
60
61
|
### Observable state
|
|
61
62
|
|
package/lib/api/expr.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
* expr can be used to create temporarily views inside views.
|
|
3
|
+
* This can be improved to improve performance if a value changes often, but usually doesn't affect the outcome of an expression.
|
|
4
|
+
*
|
|
5
|
+
* In the following example the expression prevents that a component is rerender _each time_ the selection changes;
|
|
6
|
+
* instead it will only rerenders when the current todo is (de)selected.
|
|
7
|
+
*
|
|
8
|
+
* reactiveComponent((props) => {
|
|
9
|
+
* const todo = props.todo;
|
|
10
|
+
* const isSelected = mobx.expr(() => props.viewState.selection === todo);
|
|
11
|
+
* return <div className={isSelected ? "todo todo-selected" : "todo"}>{todo.title}</div>
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
15
|
export declare function expr<T>(expr: () => T, scope?: any): T;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Lambda } from
|
|
2
|
-
import { IObservableArray } from
|
|
3
|
-
import { ObservableMap } from
|
|
4
|
-
import { IObservableValue } from
|
|
1
|
+
import { Lambda } from "../utils/utils";
|
|
2
|
+
import { IObservableArray } from "../types/observablearray";
|
|
3
|
+
import { ObservableMap } from "../types/observablemap";
|
|
4
|
+
import { IObservableValue } from "../types/observablevalue";
|
|
5
5
|
export declare type ReadInterceptor<T> = (value: any) => T;
|
|
6
6
|
/** Experimental feature right now, tested indirectly via Mobx-State-Tree */
|
|
7
7
|
export declare function interceptReads<T>(value: IObservableValue<T>, handler: ReadInterceptor<T>): Lambda;
|
package/lib/api/intercept.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ export declare function intercept<T>(observableArray: IObservableArray<T>, handl
|
|
|
9
9
|
export declare function intercept<T>(observableMap: ObservableMap<T>, handler: IInterceptor<IMapWillChange<T>>): Lambda;
|
|
10
10
|
export declare function intercept<T>(observableMap: ObservableMap<T>, property: string, handler: IInterceptor<IValueWillChange<T>>): Lambda;
|
|
11
11
|
export declare function intercept(object: Object, handler: IInterceptor<IObjectWillChange>): Lambda;
|
|
12
|
-
export declare function intercept(object:
|
|
12
|
+
export declare function intercept<T extends Object, K extends keyof T>(object: T, property: K, handler: IInterceptor<IValueWillChange<any>>): Lambda;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
* Returns true if the provided value is reactive.
|
|
3
|
+
* @param value object, function or array
|
|
4
|
+
* @param property if property is specified, checks whether value.property is reactive.
|
|
5
|
+
*/
|
|
6
6
|
export declare function isObservable(value: any, property?: string): boolean;
|
package/lib/api/tojs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
* Basically, a deep clone, so that no reactive property will exist anymore.
|
|
3
|
+
*/
|
|
4
4
|
export declare function toJS<T>(source: T, detectCycles?: boolean): T;
|
|
5
5
|
export declare function toJS(source: any, detectCycles?: boolean): any;
|
|
6
6
|
export declare function toJS(source: any, detectCycles: boolean, __alreadySeen: [any, any][]): any;
|
|
@@ -11,7 +11,9 @@ export interface IComputedValue<T> {
|
|
|
11
11
|
/**
|
|
12
12
|
* A node in the state dependency root that observes other nodes, and can be observed itself.
|
|
13
13
|
*
|
|
14
|
-
* ComputedValue will remember result of the computation for duration of
|
|
14
|
+
* ComputedValue will remember the result of the computation for the duration of the batch, or
|
|
15
|
+
* while being observed.
|
|
16
|
+
*
|
|
15
17
|
* During this time it will recompute only when one of its direct dependencies changed,
|
|
16
18
|
* but only when it is being accessed with `ComputedValue.get()`.
|
|
17
19
|
*
|
package/lib/mobx.d.ts
CHANGED
|
@@ -153,7 +153,7 @@ declare const everything: {
|
|
|
153
153
|
<T>(observableMap: ObservableMap<T>, handler: IInterceptor<IMapWillChange<T>>): Lambda;
|
|
154
154
|
<T>(observableMap: ObservableMap<T>, property: string, handler: IInterceptor<IValueWillChange<T>>): Lambda;
|
|
155
155
|
(object: Object, handler: IInterceptor<IObjectWillChange>): Lambda;
|
|
156
|
-
(object:
|
|
156
|
+
<T extends Object, K extends keyof T>(object: T, property: K, handler: IInterceptor<IValueWillChange<any>>): Lambda;
|
|
157
157
|
};
|
|
158
158
|
autorun: {
|
|
159
159
|
(view: (r: IReactionPublic) => any, scope?: any): IReactionDisposer;
|