mobx 6.1.8 → 6.9.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 +224 -7
- package/README.md +54 -52
- package/dist/api/annotation.d.ts +6 -12
- package/dist/api/autorun.d.ts +4 -4
- package/dist/api/flow.d.ts +1 -0
- package/dist/api/intercept.d.ts +5 -5
- package/dist/api/object-api.d.ts +2 -0
- package/dist/api/observable.d.ts +5 -1
- package/dist/api/observe.d.ts +4 -4
- package/dist/api/tojs.d.ts +4 -1
- package/dist/api/when.d.ts +8 -0
- package/dist/core/atom.d.ts +1 -1
- package/dist/core/computedvalue.d.ts +0 -1
- package/dist/core/globalstate.d.ts +4 -0
- package/dist/core/reaction.d.ts +2 -2
- package/dist/errors.d.ts +4 -2
- package/dist/internal.d.ts +1 -0
- package/dist/mobx.cjs.development.js +1477 -1719
- package/dist/mobx.cjs.development.js.map +1 -1
- package/dist/mobx.cjs.production.min.js +1 -1
- package/dist/mobx.cjs.production.min.js.map +1 -1
- package/dist/mobx.d.ts +1 -1
- package/dist/mobx.esm.development.js +1475 -1720
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +1492 -1726
- package/dist/mobx.esm.js.map +1 -1
- package/dist/mobx.esm.production.min.js +1 -1
- package/dist/mobx.esm.production.min.js.map +1 -1
- package/dist/mobx.umd.development.js +1477 -1719
- package/dist/mobx.umd.development.js.map +1 -1
- package/dist/mobx.umd.production.min.js +1 -1
- package/dist/mobx.umd.production.min.js.map +1 -1
- package/dist/types/actionannotation.d.ts +7 -1
- package/dist/types/autoannotation.d.ts +3 -0
- package/dist/types/observablemap.d.ts +5 -4
- package/dist/types/observableobject.d.ts +6 -9
- package/dist/types/observableset.d.ts +4 -4
- package/dist/types/observablevalue.d.ts +3 -5
- package/dist/utils/utils.d.ts +4 -4
- package/package.json +1 -1
- package/src/api/action.ts +8 -3
- package/src/api/annotation.ts +14 -44
- package/src/api/autorun.ts +38 -17
- package/src/api/computed.ts +5 -2
- package/src/api/configure.ts +6 -2
- package/src/api/decorators.ts +1 -1
- package/src/api/extendobservable.ts +12 -6
- package/src/api/extras.ts +4 -2
- package/src/api/flow.ts +17 -5
- package/src/api/intercept-read.ts +4 -2
- package/src/api/intercept.ts +10 -7
- package/src/api/iscomputed.ts +14 -8
- package/src/api/isobservable.ts +10 -4
- package/src/api/makeObservable.ts +35 -36
- package/src/api/object-api.ts +42 -14
- package/src/api/observable.ts +39 -25
- package/src/api/observe.ts +9 -6
- package/src/api/tojs.ts +20 -10
- package/src/api/trace.ts +6 -2
- package/src/api/when.ts +34 -9
- package/src/core/action.ts +11 -5
- package/src/core/atom.ts +9 -2
- package/src/core/computedvalue.ts +48 -27
- package/src/core/derivation.ts +34 -12
- package/src/core/globalstate.ts +25 -7
- package/src/core/observable.ts +23 -13
- package/src/core/reaction.ts +16 -7
- package/src/core/spy.ts +20 -7
- package/src/errors.ts +16 -3
- package/src/internal.ts +1 -0
- package/src/mobx.ts +6 -2
- package/src/types/actionannotation.ts +30 -52
- package/src/types/autoannotation.ts +107 -0
- package/src/types/computedannotation.ts +7 -37
- package/src/types/dynamicobject.ts +12 -6
- package/src/types/flowannotation.ts +40 -41
- package/src/types/intercept-utils.ts +9 -3
- package/src/types/legacyobservablearray.ts +26 -3
- package/src/types/listen-utils.ts +6 -2
- package/src/types/modifiers.ts +52 -16
- package/src/types/observableannotation.ts +7 -34
- package/src/types/observablearray.ts +106 -45
- package/src/types/observablemap.ts +71 -35
- package/src/types/observableobject.ts +88 -82
- package/src/types/observableset.ts +32 -13
- package/src/types/observablevalue.ts +16 -10
- package/src/types/overrideannotation.ts +4 -2
- package/src/types/type-utils.ts +34 -12
- package/src/utils/comparer.ts +5 -1
- package/src/utils/eq.ts +45 -15
- package/src/utils/utils.ts +39 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,222 @@
|
|
|
1
1
|
# mobx
|
|
2
2
|
|
|
3
|
+
## 6.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`44a2cf42`](https://github.com/mobxjs/mobx/commit/44a2cf42dec7635f639ddbfb19202ebc710bac54) [#3590](https://github.com/mobxjs/mobx/pull/3590) Thanks [@urugator](https://github.com/urugator)! - Better support for React 18: Mobx now keeps track of a global state version, which updates with each mutation.
|
|
8
|
+
|
|
9
|
+
## 6.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`fed3ff14`](https://github.com/mobxjs/mobx/commit/fed3ff14ca4dcbc788c4678e6d3f4edf747ffdb0) [#3608](https://github.com/mobxjs/mobx/pull/3608) Thanks [@emereum](https://github.com/emereum)! - Do not expose the methods `observe_` or `intercept_` on computed values and observable values.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`42f8ac05`](https://github.com/mobxjs/mobx/commit/42f8ac057ec70c508232339016cc7249123f0fd0) [#3596](https://github.com/mobxjs/mobx/pull/3596) Thanks [@urugator](https://github.com/urugator)! - fix #3595 onBecomeObserved is not called for ObservableSet
|
|
18
|
+
|
|
19
|
+
* [`2bccc5b3`](https://github.com/mobxjs/mobx/commit/2bccc5b3ca1df6444c942c715718519d590281e0) [#3583](https://github.com/mobxjs/mobx/pull/3583) Thanks [@urugator](https://github.com/urugator)! - fix #3582: AbortSignal leaks @types/node
|
|
20
|
+
|
|
21
|
+
- [`7095fa45`](https://github.com/mobxjs/mobx/commit/7095fa4569afb538b7f153ce2b2a8078f2dbe1fc) [#3609](https://github.com/mobxjs/mobx/pull/3609) Thanks [@emereum](https://github.com/emereum)! - Restore generic types for newValue and oldValue on IValueDidChange and IBoxDidChange.
|
|
22
|
+
|
|
23
|
+
## 6.7.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- [`8cf4784f`](https://github.com/mobxjs/mobx/commit/8cf4784f53857cc977aed641bd778f2c14a080f5) [#3559](https://github.com/mobxjs/mobx/pull/3559) Thanks [@urugator](https://github.com/urugator)! - Proxied observable arrays can now safely read/write out of bound indices. See https://github.com/mobxjs/mobx/discussions/3537
|
|
28
|
+
|
|
29
|
+
* [`223e3688`](https://github.com/mobxjs/mobx/commit/223e3688631528a327c79d39e2f497c6e1506165) [#3551](https://github.com/mobxjs/mobx/pull/3551) Thanks [@deadbeef84](https://github.com/deadbeef84)! - Added new option `signal` to `when()`, to support abortion using an AbortSignal / AbortController.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- [`fe25cfed`](https://github.com/mobxjs/mobx/commit/fe25cfede0aee3bddd7fa434a14ed4b40a57ee26) [#3566](https://github.com/mobxjs/mobx/pull/3566) Thanks [@upsuper](https://github.com/upsuper)! - Make return value of reportObserved match invoke of onBecomeObserved
|
|
34
|
+
|
|
35
|
+
## 6.6.2
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- [`b375535c`](https://github.com/mobxjs/mobx/commit/b375535c422453963f5d3485a2ef5233568c12a6) [#3344](https://github.com/mobxjs/mobx/pull/3344) Thanks [@Nokel81](https://github.com/Nokel81)! - Allow readonly tuples as part of IObservableMapInitialValues
|
|
40
|
+
|
|
41
|
+
* [`7260cd41`](https://github.com/mobxjs/mobx/commit/7260cd413b1e52449523826ac239c2a197b2880f) [#3516](https://github.com/mobxjs/mobx/pull/3516) Thanks [@urugator](https://github.com/urugator)! - fix regression #3514: LegacyObservableArray compat with Safari 9.\*
|
|
42
|
+
|
|
43
|
+
- [`78d1aa23`](https://github.com/mobxjs/mobx/commit/78d1aa2362b4dc5d521518688d6ac7e2d4f7ad3a) [#3458](https://github.com/mobxjs/mobx/pull/3458) Thanks [@egilll](https://github.com/egilll)! - A slight revamp of the README, wording, and clearer links
|
|
44
|
+
|
|
45
|
+
## 6.6.1
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- [`63698d06`](https://github.com/mobxjs/mobx/commit/63698d0681988194bac5fc01851882b417b35f18) [#3427](https://github.com/mobxjs/mobx/pull/3427) Thanks [@RyanCavanaugh](https://github.com/RyanCavanaugh)! - Apply 'object' constraint where required
|
|
50
|
+
|
|
51
|
+
## 6.6.0
|
|
52
|
+
|
|
53
|
+
### Minor Changes
|
|
54
|
+
|
|
55
|
+
- [`8e204c7b`](https://github.com/mobxjs/mobx/commit/8e204c7b7d1dbad597761fa83beda77f027ee34c) [#3409](https://github.com/mobxjs/mobx/pull/3409) Thanks [@Nokel81](https://github.com/Nokel81)! - Remove observable.box type inconsistancy
|
|
56
|
+
|
|
57
|
+
## 6.5.0
|
|
58
|
+
|
|
59
|
+
### Minor Changes
|
|
60
|
+
|
|
61
|
+
- [`767baff0`](https://github.com/mobxjs/mobx/commit/767baff0373e5a5e2b7da274b25042078f9a205c) [#3338](https://github.com/mobxjs/mobx/pull/3338) Thanks [@kubk](https://github.com/kubk)! - Replace any with a generic in Set methods
|
|
62
|
+
|
|
63
|
+
## 6.4.2
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- [`2caf7e1a`](https://github.com/mobxjs/mobx/commit/2caf7e1a3504dde3d7c9bde3c6fb56ca85168018) [#3316](https://github.com/mobxjs/mobx/pull/3316) Thanks [@urugator](https://github.com/urugator)! - `requiresObservable` always takes precedence over global `reactionRequiresObservable`
|
|
68
|
+
|
|
69
|
+
## 6.4.1
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- [`d6fa9a19`](https://github.com/mobxjs/mobx/commit/d6fa9a1970ebfb8a8adaf5bf0dc73125acec2dee) [#3306](https://github.com/mobxjs/mobx/pull/3306) Thanks [@urugator](https://github.com/urugator)! - fix missing type inferrence of `observe` and `intercept` for arrays
|
|
74
|
+
|
|
75
|
+
## 6.4.0
|
|
76
|
+
|
|
77
|
+
### Minor Changes
|
|
78
|
+
|
|
79
|
+
- [`6b926833`](https://github.com/mobxjs/mobx/commit/6b926833ac7abbf92ff5c309613d2345f72527ee) [#3287](https://github.com/mobxjs/mobx/pull/3287) Thanks [@kubk](https://github.com/kubk)! - Remove any from 'merge' and 'replace' methods of ObservableMap
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- [`dee35be4`](https://github.com/mobxjs/mobx/commit/dee35be427989b6adc3c8f7ae8dc632ea66f3538) [#3300](https://github.com/mobxjs/mobx/pull/3300) Thanks [@kubk](https://github.com/kubk)! - Make the error message about Object.freeze more informative
|
|
84
|
+
|
|
85
|
+
## 6.3.13
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- [`23803202`](https://github.com/mobxjs/mobx/commit/2380320263f5edcd06d7ba6bdf02aff3fd7d305a) [#3273](https://github.com/mobxjs/mobx/pull/3273) Thanks [@urugator](https://github.com/urugator)! - fix `flow.bound` #3271
|
|
90
|
+
|
|
91
|
+
## 6.3.12
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- [`654a2013`](https://github.com/mobxjs/mobx/commit/654a2013107ac6e5bbe3851e4eed22f0c9130525) [#3257](https://github.com/mobxjs/mobx/pull/3257) Thanks [@urugator](https://github.com/urugator)! - fix: observable map initialization violates `enforceActions: "always"`
|
|
96
|
+
|
|
97
|
+
## 6.3.11
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- [`bf5da6ba`](https://github.com/mobxjs/mobx/commit/bf5da6bad982dc3d955d5f27f7fea6f94b041ea7) [#3239](https://github.com/mobxjs/mobx/pull/3239) Thanks [@bernardobelchior](https://github.com/bernardobelchior)! - Improved `toJS` jsdoc
|
|
102
|
+
|
|
103
|
+
## 6.3.10
|
|
104
|
+
|
|
105
|
+
### Patch Changes
|
|
106
|
+
|
|
107
|
+
- [`2d70798e`](https://github.com/mobxjs/mobx/commit/2d70798eb327187d93757757ceaf410a608735b2) [#3233](https://github.com/mobxjs/mobx/pull/3233) Thanks [@anderlaw](https://github.com/anderlaw)! - `eq.ts` fix comparer logic
|
|
108
|
+
|
|
109
|
+
## 6.3.9
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- [`87e5a037`](https://github.com/mobxjs/mobx/commit/87e5a03735dbc1930e54a15b5ce88ad684bc3dc1) [#3214](https://github.com/mobxjs/mobx/pull/3214) Thanks [@urugator](https://github.com/urugator)! - `requiresReaction` always takes precedence over global `computedRequiresReaction`
|
|
114
|
+
|
|
115
|
+
* [`9b90e25c`](https://github.com/mobxjs/mobx/commit/9b90e25c7bc0cdc0a07d1f847683604e86790f24) [#3198](https://github.com/mobxjs/mobx/pull/3198) Thanks [@urugator](https://github.com/urugator)! - fix `isPlainObject` impl (fixes #3197)
|
|
116
|
+
|
|
117
|
+
## 6.3.8
|
|
118
|
+
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- [`9d5e65cb`](https://github.com/mobxjs/mobx/commit/9d5e65cbd612f262d925e57cebb559f5cf36c502) [#3193](https://github.com/mobxjs/mobx/pull/3193) Thanks [@ChocolateLoverRaj](https://github.com/ChocolateLoverRaj)! - Make `IAtom['reportObserved']` return `boolean`
|
|
122
|
+
|
|
123
|
+
* [`55508af6`](https://github.com/mobxjs/mobx/commit/55508af690fa875e6affaf30f34280b3f27b6126) [#3189](https://github.com/mobxjs/mobx/pull/3189) Thanks [@RvanderLaan](https://github.com/RvanderLaan)! - Fix for RangeError in ObservableArray.replace for large arrays
|
|
124
|
+
|
|
125
|
+
## 6.3.7
|
|
126
|
+
|
|
127
|
+
### Patch Changes
|
|
128
|
+
|
|
129
|
+
- [`3a7dee6f`](https://github.com/mobxjs/mobx/commit/3a7dee6fdaddbb4b79205b054601a8020c226fcc) [#3180](https://github.com/mobxjs/mobx/pull/3180) Thanks [@kubk](https://github.com/kubk)! - Fix type inference of observe function
|
|
130
|
+
|
|
131
|
+
## 6.3.6
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- [`49468204`](https://github.com/mobxjs/mobx/commit/49468204d3bc28d15dbf383c0b7f874ca26dff30) [#3162](https://github.com/mobxjs/mobx/pull/3162) Thanks [@upsuper](https://github.com/upsuper)! - Have cancelled when reject with an error rather than a string
|
|
136
|
+
|
|
137
|
+
* [`4afb1ec2`](https://github.com/mobxjs/mobx/commit/4afb1ec24427cf8e1f768d0c6fc49d0f44f4ab8e) [#3154](https://github.com/mobxjs/mobx/pull/3154) Thanks [@urugator](https://github.com/urugator)! - `makeObservable` throws when mixing @decorator syntax with annotations
|
|
138
|
+
|
|
139
|
+
## 6.3.5
|
|
140
|
+
|
|
141
|
+
### Patch Changes
|
|
142
|
+
|
|
143
|
+
- [`4ac6b454`](https://github.com/mobxjs/mobx/commit/4ac6b45473c2e3b07c8e683cd395bc5edfaa8e15) [#3146](https://github.com/mobxjs/mobx/pull/3146) Thanks [@urugator](https://github.com/urugator)! - fix #3109: spy: computed shouldn't report update unless the value changed
|
|
144
|
+
|
|
145
|
+
## 6.3.4
|
|
146
|
+
|
|
147
|
+
### Patch Changes
|
|
148
|
+
|
|
149
|
+
- [`0dbf3eb6`](https://github.com/mobxjs/mobx/commit/0dbf3eb6eecfa9cd6cd9dc7d707e8d70927e79bf) [#3141](https://github.com/mobxjs/mobx/pull/3141) Thanks [@urugator](https://github.com/urugator)! - [spy: bound actions report correct object](https://github.com/mobxjs/mobx/discussions/3140)
|
|
150
|
+
|
|
151
|
+
## 6.3.3
|
|
152
|
+
|
|
153
|
+
### Patch Changes
|
|
154
|
+
|
|
155
|
+
- [`d78a1592`](https://github.com/mobxjs/mobx/commit/d78a15929052b96698b3355a0b4c8335750422db) [#2902](https://github.com/mobxjs/mobx/pull/2902) Thanks [@z3rog](https://github.com/z3rog)! - chore: observable use internal constants
|
|
156
|
+
|
|
157
|
+
* [`db21d85f`](https://github.com/mobxjs/mobx/commit/db21d85fcd41c6c142998f53e722ee0a0e9b5c18) [#2998](https://github.com/mobxjs/mobx/pull/2998) Thanks [@urugator](https://github.com/urugator)! - `trace()`: log when computed becomes suspended
|
|
158
|
+
`requiresReaction` warns instead of throwing
|
|
159
|
+
|
|
160
|
+
- [`b9fa119c`](https://github.com/mobxjs/mobx/commit/b9fa119c90e23d4b327763189f24c00be2fb2c26) [#3056](https://github.com/mobxjs/mobx/pull/3056) Thanks [@upsuper](https://github.com/upsuper)! - Create WHEN_TIMEOUT error earlier to capture useful stack
|
|
161
|
+
|
|
162
|
+
* [`99491ec2`](https://github.com/mobxjs/mobx/commit/99491ec2d315a3a01cdbe40d9a24d920a09cbd0e) [#2972](https://github.com/mobxjs/mobx/pull/2972) Thanks [@kk-gjyang](https://github.com/kk-gjyang)! - Polyfill `Object.is` for old/unsupported browsers
|
|
163
|
+
|
|
164
|
+
- [`0d28db8a`](https://github.com/mobxjs/mobx/commit/0d28db8a0ba99f5cce744bb83b5bd88ec45a7e41) [#2927](https://github.com/mobxjs/mobx/pull/2927) Thanks [@upsuper](https://github.com/upsuper)! - Give proper typing to opts.equals of reaction
|
|
165
|
+
|
|
166
|
+
* [`c6dc925c`](https://github.com/mobxjs/mobx/commit/c6dc925c6cf7eeff9237ee07c55927a7bbc14cb7) [#2985](https://github.com/mobxjs/mobx/pull/2985) Thanks [@fecqs](https://github.com/fecqs)! - Remove duplicate global property check
|
|
167
|
+
|
|
168
|
+
## 6.3.2
|
|
169
|
+
|
|
170
|
+
### Patch Changes
|
|
171
|
+
|
|
172
|
+
- [`4011b378`](https://github.com/mobxjs/mobx/commit/4011b3789d57e3dab0b85a835fe2979033133ce9) [#2949](https://github.com/mobxjs/mobx/pull/2949) Thanks [@urugator](https://github.com/urugator)! - fix #2948: flow ignores `autoBind` option
|
|
173
|
+
|
|
174
|
+
## 6.3.1
|
|
175
|
+
|
|
176
|
+
### Patch Changes
|
|
177
|
+
|
|
178
|
+
- [`d678ebd7`](https://github.com/mobxjs/mobx/commit/d678ebd7e54efb3aeae4541f87f5bcf93a623ec6) [#2944](https://github.com/mobxjs/mobx/pull/2944) Thanks [@urugator](https://github.com/urugator)! - Fix [#2941](https://github.com/mobxjs/mobx/issues/2941) - flow.bound replaces method on proto with bound function
|
|
179
|
+
|
|
180
|
+
## 6.3.0
|
|
181
|
+
|
|
182
|
+
### Minor Changes
|
|
183
|
+
|
|
184
|
+
- [`035bf409`](https://github.com/mobxjs/mobx/commit/035bf4096dd72d296af1fc25304adaade73cc7eb) [#2906](https://github.com/mobxjs/mobx/pull/2906) Thanks [@urugator](https://github.com/urugator)! - Provide `flow.bound` annotation/decorator
|
|
185
|
+
|
|
186
|
+
### Patch Changes
|
|
187
|
+
|
|
188
|
+
- [`3dedb4d4`](https://github.com/mobxjs/mobx/commit/3dedb4d4b5376f3991183923838da942a9a81506) [#2904](https://github.com/mobxjs/mobx/pull/2904) Thanks [@ahoisl](https://github.com/ahoisl)! - Make toJS work with computed value props
|
|
189
|
+
|
|
190
|
+
## 6.2.0
|
|
191
|
+
|
|
192
|
+
### Minor Changes
|
|
193
|
+
|
|
194
|
+
- [`bc8db3df`](https://github.com/mobxjs/mobx/commit/bc8db3df9405034999f8feb8c95ba8045c7ae008) [#2779](https://github.com/mobxjs/mobx/pull/2779) Thanks [@urugator](https://github.com/urugator)! - In mobx5 all own properties were by default observable regardless of their value. Since mobx6 we treat functional properties as `action`s or to be precise `autoAction`s. `autoAction` provides `action`'s benefits to your functions, without the need to explicitely annotate them as `actions`.
|
|
195
|
+
We think this is useful, but as a consequence, such properties are no longer `observable` and therefore non-writable and also non-enumerable. This turned out to be suprising and inconvinient to some users:
|
|
196
|
+
https://github.com/mobxjs/mobx/discussions/2760
|
|
197
|
+
https://github.com/mobxjs/mobx/discussions/2586
|
|
198
|
+
https://github.com/mobxjs/mobx/issues/2835
|
|
199
|
+
https://github.com/mobxjs/mobx/issues/2629
|
|
200
|
+
https://github.com/mobxjs/mobx/issues/2551
|
|
201
|
+
https://github.com/mobxjs/mobx/issues/2637
|
|
202
|
+
So we decided to change it: All _own_ props _including functions_ are `observable` (enumerable, writable) as in v5, but additionally all functions that become part of deeply observable structure are by default converted to `autoAction`/`flow`.
|
|
203
|
+
Note that `deep` option affects this conversion in the same way as it affects conversion of other values (object/array/map/set).
|
|
204
|
+
|
|
205
|
+
- by default all functions are converted to `autoAction`s/`flow`s
|
|
206
|
+
- by default all originally _own_ props are now observable and enumerable (as in pre v6)
|
|
207
|
+
- `deep: false` ignores _all_ property values (including functions that would be previously converted to `autoAction`/`flow`)
|
|
208
|
+
- by default _lone_ setters are converted to `action`s
|
|
209
|
+
|
|
210
|
+
### Patch Changes
|
|
211
|
+
|
|
212
|
+
- [`16cab8b1`](https://github.com/mobxjs/mobx/commit/16cab8b14cf4a0d995d3f367123abfab5aed8326) [#2806](https://github.com/mobxjs/mobx/pull/2806) Thanks [@urugator](https://github.com/urugator)! - Annotations refactor - reduced code duplication
|
|
213
|
+
|
|
214
|
+
* [`6b324edc`](https://github.com/mobxjs/mobx/commit/6b324edc69e7e9041a01e20d2e86f424046f3e25) [#2873](https://github.com/mobxjs/mobx/pull/2873) Thanks [@urugator](https://github.com/urugator)! - Fix [#2871](https://github.com/mobxjs/mobx/issues/2871): `toJS` throws with `configure({ useProxies: "ifavailable" })`
|
|
215
|
+
|
|
216
|
+
- [`b5141883`](https://github.com/mobxjs/mobx/commit/b5141883434cba86b257d68a7badff5038c14296) [#2872](https://github.com/mobxjs/mobx/pull/2872) Thanks [@urugator](https://github.com/urugator)! - Fix [#2859](https://github.com/mobxjs/mobx/issues/2859): Trace log only if derivation is actually about to re-run
|
|
217
|
+
|
|
218
|
+
* [`0945c265`](https://github.com/mobxjs/mobx/commit/0945c26513057457e1534a80558a3eb98487dc96) [#2840](https://github.com/mobxjs/mobx/pull/2840) Thanks [@iChenLei](https://github.com/iChenLei)! - export IComputedFactory typescript type definition
|
|
219
|
+
|
|
3
220
|
## 6.1.8
|
|
4
221
|
|
|
5
222
|
### Patch Changes
|
|
@@ -81,7 +298,7 @@ Support the ongoing maintenance at: https://opencollective.com/mobx
|
|
|
81
298
|
|
|
82
299
|
[`28f8a11d`](https://github.com/mobxjs/mobx/commit/28f8a11d8b94f1aca2eec4ae9c5f45c5ea2f4362) [#2641](https://github.com/mobxjs/mobx/pull/2641) Thanks [@urugator](https://github.com/urugator)!
|
|
83
300
|
|
|
84
|
-
- `action`, `computed`, `flow` defined on prototype can be
|
|
301
|
+
- `action`, `computed`, `flow` defined on prototype can be overridden by subclass via `override` annotation/decorator. Previously broken.
|
|
85
302
|
- Overriding anything defined on instance itself (`this`) is not supported and should throw. Previously partially possible or broken.
|
|
86
303
|
- Attempt to re-annotate property always throws. Previously mostly undefined outcome.
|
|
87
304
|
- All annotated and non-observable props (action/flow) are non-writable. Previously writable.
|
|
@@ -145,12 +362,12 @@ Support the ongoing maintenance at: https://opencollective.com/mobx
|
|
|
145
362
|
|
|
146
363
|
### New features
|
|
147
364
|
|
|
148
|
-
- [`makeObservable(target, annotations)`](
|
|
149
|
-
- [`makeAutoObservable(target)`](
|
|
150
|
-
- MobX 6 can be used in both modern environments, and environments that don't support Proxy. So both MobX 4 and 5 users can upgrade to 6. See [proxy support](
|
|
365
|
+
- [`makeObservable(target, annotations)`](../../docs/observable-state.md#makeobservable) is now the recommended way to make objects with a fixed shape observable, such as classes.
|
|
366
|
+
- [`makeAutoObservable(target)`](../../docs/observable-state.md#makeautoobservable) will automatically determine the annotations used by `makeObservable`. Methods will be marked as 'autoAction', so that they can be used both from a computed value or as standalone method.
|
|
367
|
+
- MobX 6 can be used in both modern environments, and environments that don't support Proxy. So both MobX 4 and 5 users can upgrade to 6. See [proxy support](../../docs/configuration.md#proxy-support) for more details.
|
|
151
368
|
- `observable.array` now supports `{ proxy: false }` as option.
|
|
152
369
|
- `reaction`'s effect function now receives the previous value seen by the reaction as second argument.
|
|
153
|
-
- `flow` can now be used as annotation as well. You might need `flowResult` in case you use TypeScript to extract the correct result type. [details](
|
|
370
|
+
- `flow` can now be used as annotation as well. You might need `flowResult` in case you use TypeScript to extract the correct result type. [details](../../docs/actions.md#using-flow-instead-of-async--await-).
|
|
154
371
|
|
|
155
372
|
### Breaking changes
|
|
156
373
|
|
|
@@ -158,7 +375,7 @@ Support the ongoing maintenance at: https://opencollective.com/mobx
|
|
|
158
375
|
|
|
159
376
|
- The `decorate` API has been removed, and needs to be replaced by `makeObservable` in the constructor of the targeted class. It accepts the same arguments. The `mobx-undecorate` can transform this automatically.
|
|
160
377
|
- When using `extendObservable` / `observable`, fields that contained functions used to be turned into observables. This is no longer the case, they will be converted into `autoActions`.
|
|
161
|
-
- [Strict mode](
|
|
378
|
+
- [Strict mode](../../docs/configuration.md#enforceactions) for actions is now enabled by default in `observed` mode.
|
|
162
379
|
- `toJS` no longer takes any options. It no longer converts Maps and Sets to plain data structures. Generic, flexible serialization of data structures is out of scope for the MobX project, and writing custom serialization methods is a much more scalable approach to serialization (tip: leverage `computed`s to define how class instances should be serialized).
|
|
163
380
|
- The methods `intercept` and `observe` are no longer exposed on observable arrays, maps and boxed observables. Import them as utility from mobx instead: `import { observe, intercept } from "mobx"`, and pass the collection as first argument: `observer(collection, callback)`. Note that we still recommend to avoid these APIs.
|
|
164
381
|
- `observableMap.toPOJO()`, `observableMap.toJS()` have been dropped. Use `new Map(observableMap)` instead if you want to convert an observable map to a plain Map shallowly.
|
|
@@ -1342,7 +1559,7 @@ function Square() {
|
|
|
1342
1559
|
|
|
1343
1560
|
- Fixed #360: Removed expensive cycle detection (cycles are still detected, but a bit later)
|
|
1344
1561
|
- Fixed #377: `toJS` serialization of Dates and Regexes preserves the original values
|
|
1345
|
-
- Fixed #379: `@action` decorated methods can now be inherited /
|
|
1562
|
+
- Fixed #379: `@action` decorated methods can now be inherited / overridden
|
|
1346
1563
|
|
|
1347
1564
|
## 2.3.3
|
|
1348
1565
|
|
package/README.md
CHANGED
|
@@ -7,33 +7,45 @@ _Simple, scalable state management._
|
|
|
7
7
|
[](https://badge.fury.io/js/mobx)
|
|
8
8
|
[](docs/backers-sponsors.md#backers)
|
|
9
9
|
[](docs/backers-sponsors.md#sponsors)
|
|
10
|
-
|
|
11
10
|
[](https://github.com/mobxjs/mobx/discussions)
|
|
11
|
+
[](https://coveralls.io/github/mobxjs/mobx?branch=main)
|
|
12
12
|
[](https://changelogs.xyz/mobx)
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
## Documentation
|
|
17
|
+
|
|
18
|
+
Documentation can be found at **[mobx.js.org](https://mobx.js.org/)**.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Sponsors
|
|
17
23
|
|
|
18
|
-
MobX is made possible by the generosity of the sponsors below, and many other [individual backers](docs/backers-sponsors.md#backers). Sponsoring directly impacts the longevity of this project.
|
|
24
|
+
MobX is made possible by the generosity of the sponsors below, and many other [individual backers](https://github.com/mobxjs/mobx/blob/main/docs/backers-sponsors.md#backers). Sponsoring directly impacts the longevity of this project.
|
|
19
25
|
|
|
20
|
-
**🥇Gold sponsors (\$3000+ total contribution):** <br/>
|
|
26
|
+
**🥇 Gold sponsors (\$3000+ total contribution):** <br/>
|
|
21
27
|
<a href="https://mendix.com/"><img src="https://mobx.js.org/assets/mendix-logo.png" align="center" width="100" title="Mendix" alt="Mendix" /></a>
|
|
28
|
+
<a href="https://www.guilded.gg/"><img src="https://mobx.js.org/assets/guilded.jpg" align="center" width="100" title="Guilded" alt="Guilded" /></a>
|
|
29
|
+
<a href="https://www.getparallax.com/"><img src="https://mobx.js.org/assets/parallax.png" align="center" width="100" title="Parallax" alt="Parallax" /></a>
|
|
22
30
|
<a href="https://frontendmasters.com/"><img src="https://mobx.js.org/assets/frontendmasters.jpg" align="center" width="100" title="Frontend Masters" alt="Frontend Masters"></a>
|
|
23
|
-
<a href="https://
|
|
31
|
+
<a href="https://www.one-beyond.com"><img src="https://mobx.js.org/assets/dcsl.png" align="center" width="100" title="One Beyond" alt="One Beyond"/></a>
|
|
24
32
|
<a href="http://auctionfrontier.com/"><img src="https://mobx.js.org/assets/auctionfrontier.jpeg" align="center" width="100" title="Auction Frontier" alt="Auction Frontier"></a>
|
|
25
|
-
<a href="https://www.
|
|
33
|
+
<a href="https://www.codefirst.co.uk/"><img src="https://mobx.js.org/assets/codefirst.png" align="center" width="100" title="CodeFirst" alt="CodeFirst"/></a>
|
|
34
|
+
<a href="https://modulz.app/"><img src="https://mobx.js.org/assets/modulz.png" align="center" width="100" title="Modulz" alt="Modulz"/></a>
|
|
26
35
|
<a href="https://coinbase.com/"><img src="https://mobx.js.org/assets/coinbase.jpeg" align="center" width="100" title="Coinbase" alt="Coinbase" /></a>
|
|
36
|
+
<a href="https://curology.com/blog/tech"><img src="https://mobx.js.org/assets/curology.png" align="center" width="100" title="Curology" alt="Curology"/></a>
|
|
37
|
+
<a href="https://opensource.facebook.com/"><img src="https://mobx.js.org/assets/fbos.jpeg" align="center" width="100" title="Facebook Open Source" alt="Facebook Open Source" /></a>
|
|
27
38
|
<a href="https://www.canva.com/"><img src="https://mobx.js.org/assets/canva.png" align="center" width="100" title="Canva" alt="Canva" /></a>
|
|
28
39
|
|
|
29
|
-
**🥈Silver sponsors (\$100+
|
|
30
|
-
|
|
31
|
-
<a href="https://
|
|
32
|
-
<a href="https://
|
|
33
|
-
<a href="https://
|
|
34
|
-
<a href="https://modulz.app/"><img src="https://mobx.js.org/assets/modulz.png" align="center" width="100" title="Modulz" alt="Modulz"/></a>
|
|
40
|
+
**🥈 Silver sponsors (\$100+ per month):**<br/>
|
|
41
|
+
|
|
42
|
+
<a href="https://casinosites.ltd.uk/?utm_source=sponsorship&utm_medium=mobx&utm_campaign=readme"><img src="https://mobx.js.org/assets/casino2.png" align="center" width="100" title="Casino Sites" alt="Casino Sites"/></a>
|
|
43
|
+
<a href="https://upper.co/?utm_source=github_mobxjs_sponsorship&utm_medium=paid_acquisition&utm_campaign=sponsorship"><img src="https://mobx.js.org/assets/upper.png" align="center" width="100" title="UPPER" alt="UPPER"/></a>
|
|
44
|
+
<a href="https://www.easeus.com/?utm_source=github_mobxjs_sponsorship&utm_medium=readme&utm_campaign=sponsorship"><img src="https://mobx.js.org/assets/easeus.png" align="center" width="100" title="EaseUS" alt="EaseUS"/></a>
|
|
35
45
|
|
|
36
|
-
**🥉Bronze sponsors (\$500+ total contributions):**<br/>
|
|
46
|
+
**🥉 Bronze sponsors (\$500+ total contributions):**<br/>
|
|
47
|
+
<a href="https://www.bugsnag.com/platforms/react-error-reporting?utm_source=MobX&utm_medium=Website&utm_content=open-source&utm_campaign=2019-community&utm_term=20190913"><img src="https://mobx.js.org/assets/bugsnag.jpg" align="center" width="100" title="Bugsnag" alt="Bugsnag"/></a>
|
|
48
|
+
<a href="https://space307.com/?utm_source=sponsorship&utm_medium=mobx&utm_campaign=readme"><img src="https://mobx.js.org/assets/space307.png" align="center" width="100" title="Space307" alt="Space307"/></a>
|
|
37
49
|
<a href="https://mantro.net/jobs/warlock"><img src="https://mobx.js.org/assets/mantro.png" align="center" width="100" title="mantro GmbH" alt="mantro GmbH"></a>
|
|
38
50
|
<a href="https://www.algolia.com/"><img src="https://mobx.js.org/assets/algolia.jpg" align="center" width="100" title="Algolia" alt="Algolia" /></a>
|
|
39
51
|
<a href="https://talentplot.com/"><img src="https://mobx.js.org/assets/talentplot.png" align="center" width="100" title="talentplot" alt="talentplot"></a>
|
|
@@ -46,27 +58,28 @@ MobX is made possible by the generosity of the sponsors below, and many other [i
|
|
|
46
58
|
|
|
47
59
|
_Anything that can be derived from the application state, should be. Automatically._
|
|
48
60
|
|
|
49
|
-
MobX is a battle
|
|
61
|
+
MobX is a battle-tested library that makes state management simple and scalable by transparently applying functional reactive programming.
|
|
50
62
|
The philosophy behind MobX is simple:
|
|
51
63
|
|
|
52
64
|
<div class="benefits">
|
|
53
65
|
<div>
|
|
54
66
|
<div class="pic">😙</div>
|
|
55
67
|
<div>
|
|
56
|
-
<
|
|
57
|
-
<p>Write minimalistic, boilerplate
|
|
58
|
-
Trying to update a record field?
|
|
59
|
-
|
|
68
|
+
<h4>Straightforward</h4>
|
|
69
|
+
<p>Write minimalistic, boilerplate-free code that captures your intent.
|
|
70
|
+
Trying to update a record field? Simply use a normal JavaScript assignment —
|
|
71
|
+
the reactivity system will detect all your changes and propagate them out to where they are being used.
|
|
72
|
+
No special tools are required when updating data in an asynchronous process.
|
|
60
73
|
</p>
|
|
61
74
|
</div>
|
|
62
75
|
</div>
|
|
63
76
|
<div>
|
|
64
77
|
<div class="pic">🚅</div>
|
|
65
78
|
<div>
|
|
66
|
-
<
|
|
79
|
+
<h4>Effortless optimal rendering</h4>
|
|
67
80
|
<p>
|
|
68
81
|
All changes to and uses of your data are tracked at runtime, building a dependency tree that captures all relations between state and output.
|
|
69
|
-
This guarantees that computations
|
|
82
|
+
This guarantees that computations that depend on your state, like React components, run only when strictly needed.
|
|
70
83
|
There is no need to manually optimize components with error-prone and sub-optimal techniques like memoization and selectors.
|
|
71
84
|
</p>
|
|
72
85
|
</div>
|
|
@@ -74,7 +87,7 @@ The philosophy behind MobX is simple:
|
|
|
74
87
|
<div>
|
|
75
88
|
<div class="pic">🤹🏻♂️</div>
|
|
76
89
|
<div>
|
|
77
|
-
<
|
|
90
|
+
<h4>Architectural freedom</h4>
|
|
78
91
|
<p>
|
|
79
92
|
MobX is unopinionated and allows you to manage your application state outside of any UI framework.
|
|
80
93
|
This makes your code decoupled, portable, and above all, easily testable.
|
|
@@ -83,6 +96,8 @@ The philosophy behind MobX is simple:
|
|
|
83
96
|
</div>
|
|
84
97
|
</div>
|
|
85
98
|
|
|
99
|
+
---
|
|
100
|
+
|
|
86
101
|
## A quick example
|
|
87
102
|
|
|
88
103
|
So what does code that uses MobX look like?
|
|
@@ -125,7 +140,7 @@ setInterval(() => {
|
|
|
125
140
|
}, 1000)
|
|
126
141
|
```
|
|
127
142
|
|
|
128
|
-
The `observer` wrapper around the `TimerView` React component
|
|
143
|
+
The `observer` wrapper around the `TimerView` React component will automatically detect that rendering
|
|
129
144
|
depends on the `timer.secondsPassed` observable, even though this relationship is not explicitly defined. The reactivity system will take care of re-rendering the component when _precisely that_ field is updated in the future.
|
|
130
145
|
|
|
131
146
|
Every event (`onClick` / `setInterval`) invokes an _action_ (`myTimer.increase` / `myTimer.reset`) that updates _observable state_ (`myTimer.secondsPassed`).
|
|
@@ -135,49 +150,36 @@ Changes in the observable state are propagated precisely to all _computations_ a
|
|
|
135
150
|
|
|
136
151
|
This conceptual picture can be applied to the above example, or any other application using MobX.
|
|
137
152
|
|
|
138
|
-
|
|
139
|
-
The philosophy and benefits of the mental model provided by MobX are also described in great detail in the blog posts [UI as an afterthought](https://michel.codes/blogs/ui-as-an-afterthought) and [How to decouple state and UI (a.k.a. you don’t need componentWillMount)](https://hackernoon.com/how-to-decouple-state-and-ui-a-k-a-you-dont-need-componentwillmount-cc90b787aa37).
|
|
140
|
-
|
|
141
|
-
<div class="cheat"><a href="https://gum.co/fSocU"><button title="Download the MobX 6 cheat sheet and sponsor the project">Download the MobX 6 cheat sheet</button></a></div>
|
|
153
|
+
## Getting started
|
|
142
154
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
> Guise, #mobx isn't pubsub, or your grandpa's observer pattern. Nay, it is a carefully orchestrated observable dimensional portal fueled by the power cosmic. It doesn't do change detection, it's actually a level 20 psionic with soul knife, slashing your viewmodel into submission.
|
|
146
|
-
|
|
147
|
-
> After using #mobx for lone projects for a few weeks, it feels awesome to introduce it to the team. Time: 1/2, Fun: 2X
|
|
148
|
-
|
|
149
|
-
> Working with #mobx is basically a continuous loop of me going “this is way too simple, it definitely won’t work” only to be proven wrong
|
|
150
|
-
|
|
151
|
-
> I have built big apps with MobX already and comparing to the one before that which was using Redux, it is simpler to read and much easier to reason about.
|
|
152
|
-
|
|
153
|
-
> The #mobx is the way I always want things to be! It's really surprising simple and fast! Totally awesome! Don't miss it!
|
|
155
|
+
To learn about the core concepts of MobX using a larger example, check out **[The gist of MobX](https://mobx.js.org/the-gist-of-mobx.html)** page, or take the **[10 minute interactive introduction to MobX and React](https://mobx.js.org/getting-started)**.
|
|
156
|
+
The philosophy and benefits of the mental model provided by MobX are also described in great detail in the blog posts [UI as an afterthought](https://michel.codes/blogs/ui-as-an-afterthought) and [How to decouple state and UI (a.k.a. you don’t need componentWillMount)](https://hackernoon.com/how-to-decouple-state-and-ui-a-k-a-you-dont-need-componentwillmount-cc90b787aa37).
|
|
154
157
|
|
|
155
|
-
## Further resources
|
|
158
|
+
## Further resources
|
|
156
159
|
|
|
157
|
-
- [MobX cheat sheet
|
|
160
|
+
- The [MobX cheat sheet](https://gum.co/fSocU) (£5) is both useful and sponsors the project
|
|
158
161
|
- [10 minute interactive introduction to MobX and React](https://mobx.js.org/getting-started)
|
|
159
162
|
- [Egghead.io course, based on MobX 3](https://egghead.io/courses/manage-complex-state-in-react-apps-with-mobx)
|
|
163
|
+
- The [MobX awesome list](https://github.com/mobxjs/awesome-mobx#awesome-mobx) – a long list of MobX resources and example projects
|
|
160
164
|
|
|
161
165
|
### The MobX book
|
|
162
166
|
|
|
163
|
-
|
|
167
|
+
<a href="https://www.packtpub.com/product/mobx-quick-start-guide/9781789344837"><img src="https://mobx.js.org/assets/book.jpg" height="120px" /></a>
|
|
164
168
|
|
|
165
|
-
|
|
169
|
+
The **[MobX Quick Start Guide](https://www.packtpub.com/product/mobx-quick-start-guide/9781789344837)** ($24.99) by [Pavan Podila](https://twitter.com/pavanpodila) and [Michel Weststrate](https://twitter.com/mweststrate) is available as an [ebook](https://www.packtpub.com/product/mobx-quick-start-guide/9781789344837), [paperback](https://www.amazon.com/MobX-Quick-Start-Guide-Supercharge/dp/1789344832), and on the [O'Reilly platform](https://www.oreilly.com/library/view/mobx-quick-start/9781789344837/) (see [preview](https://books.google.com/books?id=ALFmDwAAQBAJ&printsec=frontcover#v=onepage&q&f=false)).
|
|
166
170
|
|
|
167
171
|
### Videos
|
|
168
172
|
|
|
169
|
-
- [Introduction to MobX & React in 2020](https://www.youtube.com/watch?v=pnhIJA64ByY) by Leigh Halliday,
|
|
170
|
-
- [ReactNext 2016: Real World MobX](https://www.youtube.com/watch?v=Aws40KOx90U) by Michel Weststrate,
|
|
171
|
-
- [CityJS 2020: MobX, from mutable to immutable, to observable data](https://
|
|
172
|
-
- [OpenSourceNorth: Practical React with MobX (ES5)](https://www.youtube.com/watch?v=XGwuM_u7UeQ) by Matt Ruby,
|
|
173
|
-
- [HolyJS 2019: MobX and the unique symbiosis of predictability and speed](https://www.youtube.com/watch?v=NBYbBbjZeX4&list=PL8sJahqnzh8JJD7xahG5zXkjfM5GOgcPA&index=21&t=0s) by Michel Weststrate,
|
|
174
|
-
- [React Amsterdam 2016: State Management Is Easy](https://www.youtube.com/watch?v=ApmSsu3qnf0&feature=youtu.be) by Michel Weststrate,
|
|
175
|
-
- {🚀} [React Live 2019: Reinventing MobX](https://www.youtube.com/watch?v=P_WqKZxpX8g) by Max Gallo,
|
|
176
|
-
|
|
177
|
-
And an all around [MobX awesome list](https://github.com/mobxjs/awesome-mobx#awesome-mobx).
|
|
173
|
+
- [Introduction to MobX & React in 2020](https://www.youtube.com/watch?v=pnhIJA64ByY) by Leigh Halliday, _17 min_.
|
|
174
|
+
- [ReactNext 2016: Real World MobX](https://www.youtube.com/watch?v=Aws40KOx90U) by Michel Weststrate, _40 min_, [slides](https://docs.google.com/presentation/d/1DrI6Hc2xIPTLBkfNH8YczOcPXQTOaCIcDESdyVfG_bE/edit?usp=sharing).
|
|
175
|
+
- [CityJS 2020: MobX, from mutable to immutable, to observable data](https://youtu.be/sP7dtZm_Wx0?t=27050) by Michel Weststrate, _30 min_.
|
|
176
|
+
- [OpenSourceNorth: Practical React with MobX (ES5)](https://www.youtube.com/watch?v=XGwuM_u7UeQ) by Matt Ruby, _42 min_.
|
|
177
|
+
- [HolyJS 2019: MobX and the unique symbiosis of predictability and speed](https://www.youtube.com/watch?v=NBYbBbjZeX4&list=PL8sJahqnzh8JJD7xahG5zXkjfM5GOgcPA&index=21&t=0s) by Michel Weststrate, _59 min_.
|
|
178
|
+
- [React Amsterdam 2016: State Management Is Easy](https://www.youtube.com/watch?v=ApmSsu3qnf0&feature=youtu.be) by Michel Weststrate, _20 min_, [slides](https://speakerdeck.com/mweststrate/state-management-is-easy-introduction-to-mobx).
|
|
179
|
+
- {🚀} [React Live 2019: Reinventing MobX](https://www.youtube.com/watch?v=P_WqKZxpX8g) by Max Gallo, _27 min_.
|
|
178
180
|
|
|
179
181
|
## Credits
|
|
180
182
|
|
|
181
|
-
MobX is inspired by reactive programming principles
|
|
183
|
+
MobX is inspired by reactive programming principles, which are for example used in spreadsheets. It is inspired by model–view–viewmodel frameworks like [MeteorJS's Tracker](https://docs.meteor.com/api/tracker.html), [Knockout](https://knockoutjs.com/) and [Vue.js](https://vuejs.org/), but MobX brings _transparent functional reactive programming_ (TFRP, a concept which is further explained in the [MobX book](https://www.packtpub.com/product/mobx-quick-start-guide/9781789344837)) to the next level and provides a standalone implementation. It implements TFRP in a glitch-free, synchronous, predictable and efficient manner.
|
|
182
184
|
|
|
183
|
-
A ton of
|
|
185
|
+
A ton of credit goes to [Mendix](https://github.com/mendix), for providing the flexibility and support to maintain MobX and the chance to prove the philosophy of MobX in a real, complex, performance critical applications.
|
package/dist/api/annotation.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { ObservableObjectAdministration } from "../internal";
|
|
2
|
+
export declare const enum MakeResult {
|
|
3
|
+
Cancel = 0,
|
|
4
|
+
Break = 1,
|
|
5
|
+
Continue = 2
|
|
6
|
+
}
|
|
2
7
|
export declare type Annotation = {
|
|
3
8
|
annotationType_: string;
|
|
4
|
-
make_(adm: ObservableObjectAdministration, key: PropertyKey):
|
|
9
|
+
make_(adm: ObservableObjectAdministration, key: PropertyKey, descriptor: PropertyDescriptor, source: object): MakeResult;
|
|
5
10
|
extend_(adm: ObservableObjectAdministration, key: PropertyKey, descriptor: PropertyDescriptor, proxyTrap: boolean): boolean | null;
|
|
6
11
|
options_?: any;
|
|
7
12
|
};
|
|
@@ -9,16 +14,5 @@ export declare type AnnotationMapEntry = Annotation | true | false;
|
|
|
9
14
|
export declare type AnnotationsMap<T, AdditionalFields extends PropertyKey> = {
|
|
10
15
|
[P in Exclude<keyof T, "toString">]?: AnnotationMapEntry;
|
|
11
16
|
} & Record<AdditionalFields, AnnotationMapEntry>;
|
|
12
|
-
/**
|
|
13
|
-
* Infers the best fitting annotation from property descriptor or false if the field shoudn't be annotated
|
|
14
|
-
* - getter(+setter) -> computed
|
|
15
|
-
* - setter w/o getter -> false (ignore)
|
|
16
|
-
* - flow -> false (ignore)
|
|
17
|
-
* - generator -> flow
|
|
18
|
-
* - action -> false (ignore)
|
|
19
|
-
* - function -> action (optionally bound)
|
|
20
|
-
* - other -> defaultAnnotation
|
|
21
|
-
*/
|
|
22
|
-
export declare function inferAnnotationFromDescriptor(desc: PropertyDescriptor, defaultAnnotation: Annotation, autoBind: boolean): Annotation | false;
|
|
23
17
|
export declare function isAnnotation(thing: any): boolean;
|
|
24
18
|
export declare function isAnnotationMapEntry(thing: any): boolean;
|
package/dist/api/autorun.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ export interface IAutorunOptions {
|
|
|
17
17
|
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
18
18
|
*/
|
|
19
19
|
export declare function autorun(view: (r: IReactionPublic) => any, opts?: IAutorunOptions): IReactionDisposer;
|
|
20
|
-
export declare type IReactionOptions = IAutorunOptions & {
|
|
21
|
-
fireImmediately?:
|
|
22
|
-
equals?: IEqualsComparer<
|
|
20
|
+
export declare type IReactionOptions<T, FireImmediately extends boolean> = IAutorunOptions & {
|
|
21
|
+
fireImmediately?: FireImmediately;
|
|
22
|
+
equals?: IEqualsComparer<T>;
|
|
23
23
|
};
|
|
24
|
-
export declare function reaction<T>(expression: (r: IReactionPublic) => T, effect: (arg: T, prev: T, r: IReactionPublic) => void, opts?: IReactionOptions): IReactionDisposer;
|
|
24
|
+
export declare function reaction<T, FireImmediately extends boolean = false>(expression: (r: IReactionPublic) => T, effect: (arg: T, prev: FireImmediately extends true ? T | undefined : T, r: IReactionPublic) => void, opts?: IReactionOptions<T, FireImmediately>): IReactionDisposer;
|
package/dist/api/flow.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare type CancellablePromise<T> = Promise<T> & {
|
|
|
10
10
|
};
|
|
11
11
|
interface Flow extends Annotation, PropertyDecorator {
|
|
12
12
|
<R, Args extends any[]>(generator: (...args: Args) => Generator<any, R, any> | AsyncGenerator<any, R, any>): (...args: Args) => CancellablePromise<R>;
|
|
13
|
+
bound: Annotation & PropertyDecorator;
|
|
13
14
|
}
|
|
14
15
|
export declare const flow: Flow;
|
|
15
16
|
export declare function flowResult<T>(result: T): T extends Generator<any, infer R, any> ? CancellablePromise<R> : T extends CancellablePromise<any> ? T : never;
|
package/dist/api/intercept.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
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
|
-
export declare function intercept<T>(observableArray: IObservableArray<T>, handler: IInterceptor<IArrayWillChange<T> | IArrayWillSplice<T>>): Lambda;
|
|
4
|
-
export declare function intercept<K, V>(observableMap: ObservableMap<K, V>, handler: IInterceptor<IMapWillChange<K, V>>): Lambda;
|
|
5
|
-
export declare function intercept<V>(
|
|
6
|
-
export declare function intercept<K, V>(observableMap: ObservableMap<K, V>, property: K, handler: IInterceptor<IValueWillChange<V>>): Lambda;
|
|
3
|
+
export declare function intercept<T>(observableArray: IObservableArray<T> | Array<T>, handler: IInterceptor<IArrayWillChange<T> | IArrayWillSplice<T>>): Lambda;
|
|
4
|
+
export declare function intercept<K, V>(observableMap: ObservableMap<K, V> | Map<K, V>, handler: IInterceptor<IMapWillChange<K, V>>): Lambda;
|
|
5
|
+
export declare function intercept<V>(observableSet: ObservableSet<V> | Set<V>, handler: IInterceptor<ISetWillChange<V>>): Lambda;
|
|
6
|
+
export declare function intercept<K, V>(observableMap: ObservableMap<K, V> | Map<K, V>, property: K, handler: IInterceptor<IValueWillChange<V>>): Lambda;
|
|
7
7
|
export declare function intercept(object: object, handler: IInterceptor<IObjectWillChange>): Lambda;
|
|
8
|
-
export declare function intercept<T extends object, K extends keyof T>(object: T, property: K, handler: IInterceptor<IValueWillChange<
|
|
8
|
+
export declare function intercept<T extends object, K extends keyof T>(object: T, property: K, handler: IInterceptor<IValueWillChange<T[K]>>): Lambda;
|
package/dist/api/object-api.d.ts
CHANGED
|
@@ -32,3 +32,5 @@ export declare function has<T extends Object>(obj: T, key: string): boolean;
|
|
|
32
32
|
export declare function get<K, V>(obj: ObservableMap<K, V>, key: K): V | undefined;
|
|
33
33
|
export declare function get<T>(obj: IObservableArray<T>, index: number): T | undefined;
|
|
34
34
|
export declare function get<T extends Object>(obj: T, key: string): any;
|
|
35
|
+
export declare function apiDefineProperty(obj: Object, key: PropertyKey, descriptor: PropertyDescriptor): any;
|
|
36
|
+
export declare function apiOwnKeys(obj: Object): any;
|
package/dist/api/observable.d.ts
CHANGED
|
@@ -16,12 +16,16 @@ export declare function asCreateObservableOptions(thing: any): CreateObservableO
|
|
|
16
16
|
export declare function getEnhancerFromOptions(options: CreateObservableOptions): IEnhancer<any>;
|
|
17
17
|
export declare function getAnnotationFromOptions(options?: CreateObservableOptions): Annotation | undefined;
|
|
18
18
|
export declare function getEnhancerFromAnnotation(annotation?: Annotation): IEnhancer<any>;
|
|
19
|
+
export interface IObservableValueFactory {
|
|
20
|
+
<T>(value: T, options?: CreateObservableOptions): IObservableValue<T>;
|
|
21
|
+
<T>(value?: T, options?: CreateObservableOptions): IObservableValue<T | undefined>;
|
|
22
|
+
}
|
|
19
23
|
export interface IObservableFactory extends Annotation, PropertyDecorator {
|
|
20
24
|
<T = any>(value: T[], options?: CreateObservableOptions): IObservableArray<T>;
|
|
21
25
|
<T = any>(value: Set<T>, options?: CreateObservableOptions): ObservableSet<T>;
|
|
22
26
|
<K = any, V = any>(value: Map<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
|
|
23
27
|
<T extends object>(value: T, decorators?: AnnotationsMap<T, never>, options?: CreateObservableOptions): T;
|
|
24
|
-
box:
|
|
28
|
+
box: IObservableValueFactory;
|
|
25
29
|
array: <T = any>(initialValues?: T[], options?: CreateObservableOptions) => IObservableArray<T>;
|
|
26
30
|
set: <T = any>(initialValues?: IObservableSetInitialValues<T>, options?: CreateObservableOptions) => ObservableSet<T>;
|
|
27
31
|
map: <K = any, V = any>(initialValues?: IObservableMapInitialValues<K, V>, options?: CreateObservableOptions) => ObservableMap<K, V>;
|
package/dist/api/observe.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IArrayDidChange, 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
|
-
export declare function observe<T>(observableArray: IObservableArray<T>, listener: (change: IArrayDidChange<T>) => void, fireImmediately?: boolean): Lambda;
|
|
4
|
-
export declare function observe<V>(
|
|
5
|
-
export declare function observe<K, V>(observableMap: ObservableMap<K, V>, listener: (change: IMapDidChange<K, V>) => void, fireImmediately?: boolean): Lambda;
|
|
6
|
-
export declare function observe<K, V>(observableMap: ObservableMap<K, V>, property: K, listener: (change: IValueDidChange<V>) => void, fireImmediately?: boolean): Lambda;
|
|
3
|
+
export declare function observe<T>(observableArray: IObservableArray<T> | Array<T>, listener: (change: IArrayDidChange<T>) => void, fireImmediately?: boolean): Lambda;
|
|
4
|
+
export declare function observe<V>(observableSet: ObservableSet<V> | Set<V>, listener: (change: ISetDidChange<V>) => void, fireImmediately?: boolean): Lambda;
|
|
5
|
+
export declare function observe<K, V>(observableMap: ObservableMap<K, V> | Map<K, V>, listener: (change: IMapDidChange<K, V>) => void, fireImmediately?: boolean): Lambda;
|
|
6
|
+
export declare function observe<K, V>(observableMap: ObservableMap<K, V> | Map<K, V>, property: K, listener: (change: IValueDidChange<V>) => void, fireImmediately?: boolean): Lambda;
|
|
7
7
|
export declare function observe(object: Object, listener: (change: IObjectDidChange) => void, fireImmediately?: boolean): Lambda;
|
|
8
8
|
export declare function observe<T, K extends keyof T>(object: T, property: K, listener: (change: IValueDidChange<T[K]>) => void, fireImmediately?: boolean): Lambda;
|
package/dist/api/tojs.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3
|
+
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
4
|
+
* Computed and other non-enumerable properties are completely ignored.
|
|
5
|
+
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3
6
|
*/
|
|
4
7
|
export declare function toJS<T>(source: T, options?: any): T;
|