mobx 6.6.1 → 6.6.2

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # mobx
2
2
 
3
+ ## 6.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`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
8
+
9
+ * [`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.\*
10
+
11
+ - [`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
12
+
3
13
  ## 6.6.1
4
14
 
5
15
  ### Patch Changes
@@ -256,7 +266,7 @@ Support the ongoing maintenance at: https://opencollective.com/mobx
256
266
 
257
267
  [`28f8a11d`](https://github.com/mobxjs/mobx/commit/28f8a11d8b94f1aca2eec4ae9c5f45c5ea2f4362) [#2641](https://github.com/mobxjs/mobx/pull/2641) Thanks [@urugator](https://github.com/urugator)!
258
268
 
259
- - `action`, `computed`, `flow` defined on prototype can be overriden by subclass via `override` annotation/decorator. Previously broken.
269
+ - `action`, `computed`, `flow` defined on prototype can be overridden by subclass via `override` annotation/decorator. Previously broken.
260
270
  - Overriding anything defined on instance itself (`this`) is not supported and should throw. Previously partially possible or broken.
261
271
  - Attempt to re-annotate property always throws. Previously mostly undefined outcome.
262
272
  - All annotated and non-observable props (action/flow) are non-writable. Previously writable.
@@ -1517,7 +1527,7 @@ function Square() {
1517
1527
 
1518
1528
  - Fixed #360: Removed expensive cycle detection (cycles are still detected, but a bit later)
1519
1529
  - Fixed #377: `toJS` serialization of Dates and Regexes preserves the original values
1520
- - Fixed #379: `@action` decorated methods can now be inherited / overriden
1530
+ - Fixed #379: `@action` decorated methods can now be inherited / overridden
1521
1531
 
1522
1532
  ## 2.3.3
1523
1533
 
package/README.md CHANGED
@@ -7,13 +7,19 @@ _Simple, scalable state management._
7
7
  [![npm version](https://badge.fury.io/js/mobx.svg)](https://badge.fury.io/js/mobx)
8
8
  [![OpenCollective](https://opencollective.com/mobx/backers/badge.svg)](docs/backers-sponsors.md#backers)
9
9
  [![OpenCollective](https://opencollective.com/mobx/sponsors/badge.svg)](docs/backers-sponsors.md#sponsors)
10
-
11
10
  [![Discuss on Github](https://img.shields.io/badge/discuss%20on-GitHub-orange)](https://github.com/mobxjs/mobx/discussions)
11
+ [![Coverage Status](https://coveralls.io/repos/github/mobxjs/mobx/badge.svg?branch=main)](https://coveralls.io/github/mobxjs/mobx?branch=main)
12
12
  [![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/mobx)
13
13
 
14
14
  ---
15
15
 
16
- > Documentation for older **unsupported** V4/V5 can be [found here](https://github.com/mobxjs/mobx/blob/mobx4and5/docs/README.md), but be sure to read about [current documentation first](https://mobx.js.org/about-this-documentation.html).
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.dcsl.com/"><img src="https://mobx.js.org/assets/dcsl.png" align="center" width="100" title="DCSL Guidesmiths" alt="DCSL Guidesmiths"/></a>
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 tested library that makes state management simple and scalable by transparently applying functional reactive programming (TFRP).
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
- <h5>Straightforward</h5>
59
- <p>Write minimalistic, boilerplate free code that captures your intent.
60
- Trying to update a record field? Use the good old JavaScript assignment.
61
- Updating data in an asynchronous process? No special tools are required, the reactivity system will detect all your changes and propagate them out to where they are being used.
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
- <h5>Effortless optimal rendering</h5>
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 depending on your state, like React components, run only when strictly needed.
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
- <h5>Architectural freedom</h5>
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, will automatically detect that rendering
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
- 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) section, or take the [10 minute interactive introduction to MobX and React](https://mobx.js.org/getting-started).
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
- > 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
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 and documentation
154
+ ## Further resources
158
155
 
159
- - [MobX cheat sheet (also sponsors the project)](https://gum.co/fSocU)
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
- [<img src="https://mobx.js.org/assets/book.jpg" height="80px"/> ](https://books.google.nl/books?id=ALFmDwAAQBAJ&pg=PP1&lpg=PP1&dq=michel+weststrate+mobx+quick+start+guide:+supercharge+the+client+state+in+your+react+apps+with+mobx&source=bl&ots=D460fxti0F&sig=ivDGTxsPNwlOjLHrpKF1nweZFl8&hl=nl&sa=X&ved=2ahUKEwiwl8XO--ncAhWPmbQKHWOYBqIQ6AEwAnoECAkQAQ#v=onepage&q=michel%20weststrate%20mobx%20quick%20start%20guide%3A%20supercharge%20the%20client%20state%20in%20your%20react%20apps%20with%20mobx&f=false)
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
- Created by [Pavan Podila](https://twitter.com/pavanpodila) and [Michel Weststrate](https://twitter.com/mweststrate).
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, _17min_.
172
- - [ReactNext 2016: Real World MobX](https://www.youtube.com/watch?v=Aws40KOx90U) by Michel Weststrate, _40min_, [slides](https://docs.google.com/presentation/d/1DrI6Hc2xIPTLBkfNH8YczOcPXQTOaCIcDESdyVfG_bE/edit?usp=sharing).
173
- - [CityJS 2020: MobX, from mutable to immutable, to observable data](https://www.youtube.com/watch?v=ZHxFrbK3VB0&feature=emb_logo) by Michel Weststrate, _30min_.
174
- - [OpenSourceNorth: Practical React with MobX (ES5)](https://www.youtube.com/watch?v=XGwuM_u7UeQ) by Matt Ruby, _42min_.
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, _59min_.
176
- - [React Amsterdam 2016: State Management Is Easy](https://www.youtube.com/watch?v=ApmSsu3qnf0&feature=youtu.be) by Michel Weststrate, _20min_, [slides](https://speakerdeck.com/mweststrate/state-management-is-easy-introduction-to-mobx).
177
- - {🚀} [React Live 2019: Reinventing MobX](https://www.youtube.com/watch?v=P_WqKZxpX8g) by Max Gallo, _27min_.
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 as found in the spreadsheets. It is inspired by MVVM frameworks like MeteorJS tracker, knockout and Vue.js, but MobX brings _Transparent Functional Reactive Programming_ to the next level and provides a standalone implementation. It implements TFRP in a glitch-free, synchronous, predictable and efficient manner.
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 credits goes to [Mendix](https://github.com/mendix), for providing the flexibility and support to maintain MobX and the chance to proof the philosophy of MobX in a real, complex, performance critical applications.
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.
@@ -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 overriden by subclass.");
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
  /**
@@ -5987,16 +5987,18 @@ function assertAnnotable(adm, annotation, key) {
5987
5987
  var fieldName = adm.name_ + "." + key.toString();
5988
5988
  var currentAnnotationType = adm.appliedAnnotations_[key].annotationType_;
5989
5989
  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 overriden by subclass.");
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 overridden by subclass.");
5991
5991
  }
5992
5992
  }
5993
5993
 
5994
+ var ENTRY_0 = /*#__PURE__*/createArrayEntryDescriptor(0);
5994
5995
  /**
5995
5996
  * This array buffer contains two lists of properties, so that all arrays
5996
5997
  * can recycle their property definitions, which significantly improves performance of creating
5997
5998
  * properties on the fly.
5998
5999
  */
5999
6000
 
6001
+
6000
6002
  var OBSERVABLE_ARRAY_BUFFER_SIZE = 0; // Typescript workaround to make sure ObservableArray extends Array
6001
6003
 
6002
6004
  var StubArray = function StubArray() {};
@@ -6042,6 +6044,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
6042
6044
  allowStateChangesEnd(prev);
6043
6045
  }
6044
6046
 
6047
+ {
6048
+ // Seems that Safari won't use numeric prototype setter untill any * numeric property is
6049
+ // defined on the instance. After that it works fine, even if this property is deleted.
6050
+ Object.defineProperty(_assertThisInitialized(_this), "0", ENTRY_0);
6051
+ }
6052
+
6045
6053
  return _this;
6046
6054
  }
6047
6055