mobx 6.6.1 → 6.7.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 +24 -2
- package/README.md +38 -42
- package/dist/api/when.d.ts +2 -0
- package/dist/mobx.cjs.development.js +57 -12
- 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.esm.development.js +57 -12
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +57 -12
- 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 +57 -12
- 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/observablemap.d.ts +3 -1
- package/package.json +1 -1
- package/src/api/decorators.ts +1 -1
- package/src/api/when.ts +11 -1
- package/src/core/observable.ts +1 -1
- package/src/types/legacyobservablearray.ts +21 -0
- package/src/types/observablearray.ts +23 -14
- package/src/types/observablemap.ts +4 -2
- package/src/types/observableobject.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# mobx
|
|
2
2
|
|
|
3
|
+
## 6.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`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
|
|
8
|
+
|
|
9
|
+
* [`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.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`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
|
|
14
|
+
|
|
15
|
+
## 6.6.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`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
|
|
20
|
+
|
|
21
|
+
* [`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.\*
|
|
22
|
+
|
|
23
|
+
- [`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
|
|
24
|
+
|
|
3
25
|
## 6.6.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -256,7 +278,7 @@ Support the ongoing maintenance at: https://opencollective.com/mobx
|
|
|
256
278
|
|
|
257
279
|
[`28f8a11d`](https://github.com/mobxjs/mobx/commit/28f8a11d8b94f1aca2eec4ae9c5f45c5ea2f4362) [#2641](https://github.com/mobxjs/mobx/pull/2641) Thanks [@urugator](https://github.com/urugator)!
|
|
258
280
|
|
|
259
|
-
- `action`, `computed`, `flow` defined on prototype can be
|
|
281
|
+
- `action`, `computed`, `flow` defined on prototype can be overridden by subclass via `override` annotation/decorator. Previously broken.
|
|
260
282
|
- Overriding anything defined on instance itself (`this`) is not supported and should throw. Previously partially possible or broken.
|
|
261
283
|
- Attempt to re-annotate property always throws. Previously mostly undefined outcome.
|
|
262
284
|
- All annotated and non-observable props (action/flow) are non-writable. Previously writable.
|
|
@@ -1517,7 +1539,7 @@ function Square() {
|
|
|
1517
1539
|
|
|
1518
1540
|
- Fixed #360: Removed expensive cycle detection (cycles are still detected, but a bit later)
|
|
1519
1541
|
- Fixed #377: `toJS` serialization of Dates and Regexes preserves the original values
|
|
1520
|
-
- Fixed #379: `@action` decorated methods can now be inherited /
|
|
1542
|
+
- Fixed #379: `@action` decorated methods can now be inherited / overridden
|
|
1521
1543
|
|
|
1522
1544
|
## 2.3.3
|
|
1523
1545
|
|
package/README.md
CHANGED
|
@@ -7,13 +7,19 @@ _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
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
|
|
|
@@ -28,7 +34,7 @@ MobX is made possible by the generosity of the sponsors below, and many other [i
|
|
|
28
34
|
|
|
29
35
|
**🥈 Silver sponsors (\$100+ per month):**<br/>
|
|
30
36
|
<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>
|
|
31
|
-
<a href="https://www.
|
|
37
|
+
<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>
|
|
32
38
|
<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>
|
|
33
39
|
<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>
|
|
34
40
|
<a href="https://modulz.app/"><img src="https://mobx.js.org/assets/modulz.png" align="center" width="100" title="Modulz" alt="Modulz"/></a>
|
|
@@ -48,27 +54,28 @@ MobX is made possible by the generosity of the sponsors below, and many other [i
|
|
|
48
54
|
|
|
49
55
|
_Anything that can be derived from the application state, should be. Automatically._
|
|
50
56
|
|
|
51
|
-
MobX is a battle
|
|
57
|
+
MobX is a battle-tested library that makes state management simple and scalable by transparently applying functional reactive programming.
|
|
52
58
|
The philosophy behind MobX is simple:
|
|
53
59
|
|
|
54
60
|
<div class="benefits">
|
|
55
61
|
<div>
|
|
56
62
|
<div class="pic">😙</div>
|
|
57
63
|
<div>
|
|
58
|
-
<
|
|
59
|
-
<p>Write minimalistic, boilerplate
|
|
60
|
-
Trying to update a record field?
|
|
61
|
-
|
|
64
|
+
<h4>Straightforward</h4>
|
|
65
|
+
<p>Write minimalistic, boilerplate-free code that captures your intent.
|
|
66
|
+
Trying to update a record field? Simply use a normal JavaScript assignment —
|
|
67
|
+
the reactivity system will detect all your changes and propagate them out to where they are being used.
|
|
68
|
+
No special tools are required when updating data in an asynchronous process.
|
|
62
69
|
</p>
|
|
63
70
|
</div>
|
|
64
71
|
</div>
|
|
65
72
|
<div>
|
|
66
73
|
<div class="pic">🚅</div>
|
|
67
74
|
<div>
|
|
68
|
-
<
|
|
75
|
+
<h4>Effortless optimal rendering</h4>
|
|
69
76
|
<p>
|
|
70
77
|
All changes to and uses of your data are tracked at runtime, building a dependency tree that captures all relations between state and output.
|
|
71
|
-
This guarantees that computations
|
|
78
|
+
This guarantees that computations that depend on your state, like React components, run only when strictly needed.
|
|
72
79
|
There is no need to manually optimize components with error-prone and sub-optimal techniques like memoization and selectors.
|
|
73
80
|
</p>
|
|
74
81
|
</div>
|
|
@@ -76,7 +83,7 @@ The philosophy behind MobX is simple:
|
|
|
76
83
|
<div>
|
|
77
84
|
<div class="pic">🤹🏻♂️</div>
|
|
78
85
|
<div>
|
|
79
|
-
<
|
|
86
|
+
<h4>Architectural freedom</h4>
|
|
80
87
|
<p>
|
|
81
88
|
MobX is unopinionated and allows you to manage your application state outside of any UI framework.
|
|
82
89
|
This makes your code decoupled, portable, and above all, easily testable.
|
|
@@ -85,6 +92,8 @@ The philosophy behind MobX is simple:
|
|
|
85
92
|
</div>
|
|
86
93
|
</div>
|
|
87
94
|
|
|
95
|
+
---
|
|
96
|
+
|
|
88
97
|
## A quick example
|
|
89
98
|
|
|
90
99
|
So what does code that uses MobX look like?
|
|
@@ -127,7 +136,7 @@ setInterval(() => {
|
|
|
127
136
|
}, 1000)
|
|
128
137
|
```
|
|
129
138
|
|
|
130
|
-
The `observer` wrapper around the `TimerView` React component
|
|
139
|
+
The `observer` wrapper around the `TimerView` React component will automatically detect that rendering
|
|
131
140
|
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.
|
|
132
141
|
|
|
133
142
|
Every event (`onClick` / `setInterval`) invokes an _action_ (`myTimer.increase` / `myTimer.reset`) that updates _observable state_ (`myTimer.secondsPassed`).
|
|
@@ -137,49 +146,36 @@ Changes in the observable state are propagated precisely to all _computations_ a
|
|
|
137
146
|
|
|
138
147
|
This conceptual picture can be applied to the above example, or any other application using MobX.
|
|
139
148
|
|
|
140
|
-
|
|
141
|
-
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).
|
|
142
|
-
|
|
143
|
-
<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>
|
|
144
|
-
|
|
145
|
-
## What others are saying...
|
|
146
|
-
|
|
147
|
-
> 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.
|
|
148
|
-
|
|
149
|
-
> After using #mobx for lone projects for a few weeks, it feels awesome to introduce it to the team. Time: 1/2, Fun: 2X
|
|
149
|
+
## Getting started
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
> 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.
|
|
154
|
-
|
|
155
|
-
> The #mobx is the way I always want things to be! It's really surprising simple and fast! Totally awesome! Don't miss it!
|
|
151
|
+
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)**.
|
|
152
|
+
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).
|
|
156
153
|
|
|
157
|
-
## Further resources
|
|
154
|
+
## Further resources
|
|
158
155
|
|
|
159
|
-
- [MobX cheat sheet
|
|
156
|
+
- The [MobX cheat sheet](https://gum.co/fSocU) (£5) is both useful and sponsors the project
|
|
160
157
|
- [10 minute interactive introduction to MobX and React](https://mobx.js.org/getting-started)
|
|
161
158
|
- [Egghead.io course, based on MobX 3](https://egghead.io/courses/manage-complex-state-in-react-apps-with-mobx)
|
|
159
|
+
- The [MobX awesome list](https://github.com/mobxjs/awesome-mobx#awesome-mobx) – a long list of MobX resources and example projects
|
|
162
160
|
|
|
163
161
|
### The MobX book
|
|
164
162
|
|
|
165
|
-
|
|
163
|
+
<a href="https://www.packtpub.com/product/mobx-quick-start-guide/9781789344837"><img src="https://mobx.js.org/assets/book.jpg" height="120px" /></a>
|
|
166
164
|
|
|
167
|
-
|
|
165
|
+
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)).
|
|
168
166
|
|
|
169
167
|
### Videos
|
|
170
168
|
|
|
171
|
-
- [Introduction to MobX & React in 2020](https://www.youtube.com/watch?v=pnhIJA64ByY) by Leigh Halliday,
|
|
172
|
-
- [ReactNext 2016: Real World MobX](https://www.youtube.com/watch?v=Aws40KOx90U) by Michel Weststrate,
|
|
173
|
-
- [CityJS 2020: MobX, from mutable to immutable, to observable data](https://
|
|
174
|
-
- [OpenSourceNorth: Practical React with MobX (ES5)](https://www.youtube.com/watch?v=XGwuM_u7UeQ) by Matt Ruby,
|
|
175
|
-
- [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,
|
|
176
|
-
- [React Amsterdam 2016: State Management Is Easy](https://www.youtube.com/watch?v=ApmSsu3qnf0&feature=youtu.be) by Michel Weststrate,
|
|
177
|
-
- {🚀} [React Live 2019: Reinventing MobX](https://www.youtube.com/watch?v=P_WqKZxpX8g) by Max Gallo,
|
|
178
|
-
|
|
179
|
-
And an all around [MobX awesome list](https://github.com/mobxjs/awesome-mobx#awesome-mobx).
|
|
169
|
+
- [Introduction to MobX & React in 2020](https://www.youtube.com/watch?v=pnhIJA64ByY) by Leigh Halliday, _17 min_.
|
|
170
|
+
- [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).
|
|
171
|
+
- [CityJS 2020: MobX, from mutable to immutable, to observable data](https://youtu.be/sP7dtZm_Wx0?t=27050) by Michel Weststrate, _30 min_.
|
|
172
|
+
- [OpenSourceNorth: Practical React with MobX (ES5)](https://www.youtube.com/watch?v=XGwuM_u7UeQ) by Matt Ruby, _42 min_.
|
|
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, _59 min_.
|
|
174
|
+
- [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).
|
|
175
|
+
- {🚀} [React Live 2019: Reinventing MobX](https://www.youtube.com/watch?v=P_WqKZxpX8g) by Max Gallo, _27 min_.
|
|
180
176
|
|
|
181
177
|
## Credits
|
|
182
178
|
|
|
183
|
-
MobX is inspired by reactive programming principles
|
|
179
|
+
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.
|
|
184
180
|
|
|
185
|
-
A ton of
|
|
181
|
+
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/when.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { IReactionDisposer, Lambda } from "../internal";
|
|
2
3
|
export interface IWhenOptions {
|
|
3
4
|
name?: string;
|
|
4
5
|
timeout?: number;
|
|
5
6
|
onError?: (error: any) => void;
|
|
7
|
+
signal?: AbortSignal;
|
|
6
8
|
}
|
|
7
9
|
export declare function when(predicate: () => boolean, opts?: IWhenOptions): Promise<void> & {
|
|
8
10
|
cancel(): void;
|
|
@@ -426,7 +426,7 @@ function assertNotDecorated(prototype, annotation, key) {
|
|
|
426
426
|
var fieldName = prototype.constructor.name + ".prototype." + key.toString();
|
|
427
427
|
var currentAnnotationType = prototype[storedAnnotationsSymbol][key].annotationType_;
|
|
428
428
|
var requestedAnnotationType = annotation.annotationType_;
|
|
429
|
-
die("Cannot apply '@" + requestedAnnotationType + "' to '" + fieldName + "':" + ("\nThe field is already decorated with '@" + currentAnnotationType + "'.") + "\nRe-decorating fields is not allowed." + "\nUse '@override' decorator for methods
|
|
429
|
+
die("Cannot apply '@" + requestedAnnotationType + "' to '" + fieldName + "':" + ("\nThe field is already decorated with '@" + currentAnnotationType + "'.") + "\nRe-decorating fields is not allowed." + "\nUse '@override' decorator for methods overridden by subclass.");
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
/**
|
|
@@ -2318,7 +2318,7 @@ function reportObserved(observable) {
|
|
|
2318
2318
|
}
|
|
2319
2319
|
}
|
|
2320
2320
|
|
|
2321
|
-
return
|
|
2321
|
+
return observable.isBeingObserved_;
|
|
2322
2322
|
} else if (observable.observers_.size === 0 && globalState.inBatch > 0) {
|
|
2323
2323
|
queueForUnobservation(observable);
|
|
2324
2324
|
}
|
|
@@ -3685,12 +3685,25 @@ function _when(predicate, effect, opts) {
|
|
|
3685
3685
|
}
|
|
3686
3686
|
|
|
3687
3687
|
function whenPromise(predicate, opts) {
|
|
3688
|
+
var _opts$signal;
|
|
3689
|
+
|
|
3688
3690
|
if ( opts && opts.onError) {
|
|
3689
3691
|
return die("the options 'onError' and 'promise' cannot be combined");
|
|
3690
3692
|
}
|
|
3691
3693
|
|
|
3694
|
+
if (opts != null && (_opts$signal = opts.signal) != null && _opts$signal.aborted) {
|
|
3695
|
+
return Object.assign(Promise.reject(new Error("WHEN_ABORTED")), {
|
|
3696
|
+
cancel: function cancel() {
|
|
3697
|
+
return null;
|
|
3698
|
+
}
|
|
3699
|
+
});
|
|
3700
|
+
}
|
|
3701
|
+
|
|
3692
3702
|
var cancel;
|
|
3703
|
+
var abort;
|
|
3693
3704
|
var res = new Promise(function (resolve, reject) {
|
|
3705
|
+
var _opts$signal2;
|
|
3706
|
+
|
|
3694
3707
|
var disposer = _when(predicate, resolve, _extends({}, opts, {
|
|
3695
3708
|
onError: reject
|
|
3696
3709
|
}));
|
|
@@ -3699,6 +3712,17 @@ function whenPromise(predicate, opts) {
|
|
|
3699
3712
|
disposer();
|
|
3700
3713
|
reject(new Error("WHEN_CANCELLED"));
|
|
3701
3714
|
};
|
|
3715
|
+
|
|
3716
|
+
abort = function abort() {
|
|
3717
|
+
disposer();
|
|
3718
|
+
reject(new Error("WHEN_ABORTED"));
|
|
3719
|
+
};
|
|
3720
|
+
|
|
3721
|
+
opts == null ? void 0 : (_opts$signal2 = opts.signal) == null ? void 0 : _opts$signal2.addEventListener("abort", abort);
|
|
3722
|
+
})["finally"](function () {
|
|
3723
|
+
var _opts$signal3;
|
|
3724
|
+
|
|
3725
|
+
return opts == null ? void 0 : (_opts$signal3 = opts.signal) == null ? void 0 : _opts$signal3.removeEventListener("abort", abort);
|
|
3702
3726
|
});
|
|
3703
3727
|
res.cancel = cancel;
|
|
3704
3728
|
return res;
|
|
@@ -4217,17 +4241,23 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
4217
4241
|
};
|
|
4218
4242
|
|
|
4219
4243
|
_proto.get_ = function get_(index) {
|
|
4220
|
-
if (index
|
|
4221
|
-
|
|
4222
|
-
return
|
|
4244
|
+
if (this.legacyMode_ && index >= this.values_.length) {
|
|
4245
|
+
console.warn( "[mobx.array] Attempt to read an array index (" + index + ") that is out of bounds (" + this.values_.length + "). Please check length first. Out of bound indices will not be tracked by MobX" );
|
|
4246
|
+
return undefined;
|
|
4223
4247
|
}
|
|
4224
4248
|
|
|
4225
|
-
|
|
4249
|
+
this.atom_.reportObserved();
|
|
4250
|
+
return this.dehanceValue_(this.values_[index]);
|
|
4226
4251
|
};
|
|
4227
4252
|
|
|
4228
4253
|
_proto.set_ = function set_(index, newValue) {
|
|
4229
4254
|
var values = this.values_;
|
|
4230
4255
|
|
|
4256
|
+
if (this.legacyMode_ && index > values.length) {
|
|
4257
|
+
// out of bounds
|
|
4258
|
+
die(17, index, values.length);
|
|
4259
|
+
}
|
|
4260
|
+
|
|
4231
4261
|
if (index < values.length) {
|
|
4232
4262
|
// update at index in range
|
|
4233
4263
|
checkIfStateModificationsAreAllowed(this.atom_);
|
|
@@ -4255,12 +4285,19 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
4255
4285
|
values[index] = newValue;
|
|
4256
4286
|
this.notifyArrayChildUpdate_(index, newValue, oldValue);
|
|
4257
4287
|
}
|
|
4258
|
-
} else if (index === values.length) {
|
|
4259
|
-
// add a new item
|
|
4260
|
-
this.spliceWithArray_(index, 0, [newValue]);
|
|
4261
4288
|
} else {
|
|
4262
|
-
// out of
|
|
4263
|
-
|
|
4289
|
+
// For out of bound index, we don't create an actual sparse array,
|
|
4290
|
+
// but rather fill the holes with undefined (same as setArrayLength_).
|
|
4291
|
+
// This could be considered a bug.
|
|
4292
|
+
var newItems = new Array(index + 1 - values.length);
|
|
4293
|
+
|
|
4294
|
+
for (var i = 0; i < newItems.length - 1; i++) {
|
|
4295
|
+
newItems[i] = undefined;
|
|
4296
|
+
} // No Array.fill everywhere...
|
|
4297
|
+
|
|
4298
|
+
|
|
4299
|
+
newItems[newItems.length - 1] = newValue;
|
|
4300
|
+
this.spliceWithArray_(values.length, 0, newItems);
|
|
4264
4301
|
}
|
|
4265
4302
|
};
|
|
4266
4303
|
|
|
@@ -5987,16 +6024,18 @@ function assertAnnotable(adm, annotation, key) {
|
|
|
5987
6024
|
var fieldName = adm.name_ + "." + key.toString();
|
|
5988
6025
|
var currentAnnotationType = adm.appliedAnnotations_[key].annotationType_;
|
|
5989
6026
|
var requestedAnnotationType = annotation.annotationType_;
|
|
5990
|
-
die("Cannot apply '" + requestedAnnotationType + "' to '" + fieldName + "':" + ("\nThe field is already annotated with '" + currentAnnotationType + "'.") + "\nRe-annotating fields is not allowed." + "\nUse 'override' annotation for methods
|
|
6027
|
+
die("Cannot apply '" + requestedAnnotationType + "' to '" + fieldName + "':" + ("\nThe field is already annotated with '" + currentAnnotationType + "'.") + "\nRe-annotating fields is not allowed." + "\nUse 'override' annotation for methods overridden by subclass.");
|
|
5991
6028
|
}
|
|
5992
6029
|
}
|
|
5993
6030
|
|
|
6031
|
+
var ENTRY_0 = /*#__PURE__*/createArrayEntryDescriptor(0);
|
|
5994
6032
|
/**
|
|
5995
6033
|
* This array buffer contains two lists of properties, so that all arrays
|
|
5996
6034
|
* can recycle their property definitions, which significantly improves performance of creating
|
|
5997
6035
|
* properties on the fly.
|
|
5998
6036
|
*/
|
|
5999
6037
|
|
|
6038
|
+
|
|
6000
6039
|
var OBSERVABLE_ARRAY_BUFFER_SIZE = 0; // Typescript workaround to make sure ObservableArray extends Array
|
|
6001
6040
|
|
|
6002
6041
|
var StubArray = function StubArray() {};
|
|
@@ -6042,6 +6081,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
6042
6081
|
allowStateChangesEnd(prev);
|
|
6043
6082
|
}
|
|
6044
6083
|
|
|
6084
|
+
{
|
|
6085
|
+
// Seems that Safari won't use numeric prototype setter untill any * numeric property is
|
|
6086
|
+
// defined on the instance. After that it works fine, even if this property is deleted.
|
|
6087
|
+
Object.defineProperty(_assertThisInitialized(_this), "0", ENTRY_0);
|
|
6088
|
+
}
|
|
6089
|
+
|
|
6045
6090
|
return _this;
|
|
6046
6091
|
}
|
|
6047
6092
|
|