Skip to content

Commit 4ebf596

Browse files
authored
Doc improvements (#2725)
* docs: Document enumerability as discussed in #2641 * docs: Document `proxy` option as discussed in #2717 * docs: use absolute urls in Readme, fixes #2685 * Add changeset * Name fix
1 parent dea1cf1 commit 4ebf596

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

.changeset/rude-berries-stare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
3+
---
4+
5+
Several documentation improvements, fixes #2685.

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<img src="docs/assets/mobx.png" alt="logo" height="120" align="right" />
1+
<img src="https://mobx.js.org/docs/assets/mobx.png" alt="logo" height="120" align="right" />
22

33
# MobX
44

@@ -13,32 +13,32 @@ _Simple, scalable state management._
1313

1414
---
1515

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 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).
1717
1818
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.
1919

2020
**🥇Gold sponsors (\$3000+ total contribution):** <br/>
21-
<a href="https://mendix.com/"><img src="docs/assets/mendix-logo.png" align="center" width="100" title="Mendix" alt="Mendix" /></a>
22-
<a href="https://frontendmasters.com/"><img src="docs/assets/frontendmasters.jpg" align="center" width="100" title="Frontend Masters" alt="Frontend Masters"></a>
23-
<a href="https://opensource.facebook.com/"><img src="docs/assets/fbos.jpeg" align="center" width="100" title="Facebook Open Source" alt="Facebook Open Source" /></a>
24-
<a href="http://auctionfrontier.com/"><img src="docs/assets/auctionfrontier.jpeg" align="center" width="100" title="Auction Frontier" alt="Auction Frontier"></a>
25-
<a href="https://www.guilded.gg/"><img src="docs/assets/guilded.jpg" align="center" width="100" title="Guilded" alt="Guilded" /></a>
26-
<a href="https://coinbase.com/"><img src="docs/assets/coinbase.jpeg" align="center" width="100" title="Coinbase" alt="Coinbase" /></a>
27-
<a href="https://www.canva.com/"><img src="docs/assets/canva.png" align="center" width="100" title="Canva" alt="Canva" /></a>
21+
<a href="https://mendix.com/"><img src="https://mobx.js.org/docs/assets/mendix-logo.png" align="center" width="100" title="Mendix" alt="Mendix" /></a>
22+
<a href="https://frontendmasters.com/"><img src="https://mobx.js.org/docs/assets/frontendmasters.jpg" align="center" width="100" title="Frontend Masters" alt="Frontend Masters"></a>
23+
<a href="https://opensource.facebook.com/"><img src="https://mobx.js.org/docs/assets/fbos.jpeg" align="center" width="100" title="Facebook Open Source" alt="Facebook Open Source" /></a>
24+
<a href="http://auctionfrontier.com/"><img src="https://mobx.js.org/docs/assets/auctionfrontier.jpeg" align="center" width="100" title="Auction Frontier" alt="Auction Frontier"></a>
25+
<a href="https://www.guilded.gg/"><img src="https://mobx.js.org/docs/assets/guilded.jpg" align="center" width="100" title="Guilded" alt="Guilded" /></a>
26+
<a href="https://coinbase.com/"><img src="https://mobx.js.org/docs/assets/coinbase.jpeg" align="center" width="100" title="Coinbase" alt="Coinbase" /></a>
27+
<a href="https://www.canva.com/"><img src="https://mobx.js.org/docs/assets/canva.png" align="center" width="100" title="Canva" alt="Canva" /></a>
2828

2929
**🥈Silver sponsors (\$100+ pm):**<br/>
30-
<a href="https://www.codefirst.co.uk/"><img src="docs/assets/codefirst.png" align="center" width="100" title="CodeFirst" alt="CodeFirst"/></a>
31-
<a href="https://www.dcslsoftware.com/"><img src="docs/assets/dcsl.png" align="center" width="100" title="DCSL Software" alt="DCSL Software"/></a>
32-
<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="docs/assets/bugsnag.jpg" align="center" width="100" title="Bugsnag" alt="Bugsnag"/></a>
33-
<a href="https://curology.com/blog/tech"><img src="docs/assets/curology.png" align="center" width="100" title="Curology" alt="Curology"/></a>
34-
<a href="https://modulz.app/"><img src="docs/assets/modulz.png" align="center" width="100" title="Modulz" alt="Modulz"/></a>
30+
<a href="https://www.codefirst.co.uk/"><img src="https://mobx.js.org/docs/assets/codefirst.png" align="center" width="100" title="CodeFirst" alt="CodeFirst"/></a>
31+
<a href="https://www.dcslsoftware.com/"><img src="https://mobx.js.org/docs/assets/dcsl.png" align="center" width="100" title="DCSL Software" alt="DCSL Software"/></a>
32+
<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/docs/assets/bugsnag.jpg" align="center" width="100" title="Bugsnag" alt="Bugsnag"/></a>
33+
<a href="https://curology.com/blog/tech"><img src="https://mobx.js.org/docs/assets/curology.png" align="center" width="100" title="Curology" alt="Curology"/></a>
34+
<a href="https://modulz.app/"><img src="https://mobx.js.org/docs/assets/modulz.png" align="center" width="100" title="Modulz" alt="Modulz"/></a>
3535

3636
**🥉Bronze sponsors (\$500+ total contributions):**<br/>
37-
<a href="https://mantro.net/jobs/warlock"><img src="docs/assets/mantro.png" align="center" width="100" title="mantro GmbH" alt="mantro GmbH"></a>
38-
<a href="https://www.algolia.com/"><img src="docs/assets/algolia.jpg" align="center" width="100" title="Algolia" alt="Algolia" /></a>
39-
<a href="https://talentplot.com/"><img src="docs/assets/talentplot.png" align="center" width="100" title="talentplot" alt="talentplot"></a>
40-
<a href="https://careers.dazn.com/"><img src="docs/assets/dazn.png" align="center" width="100" title="DAZN" alt="DAZN"></a>
41-
<a href="https://blokt.com/"><img src="docs/assets/blokt.jpg" align="center" width="100" title="Blokt" alt="Blokt"/></a>
37+
<a href="https://mantro.net/jobs/warlock"><img src="https://mobx.js.org/docs/assets/mantro.png" align="center" width="100" title="mantro GmbH" alt="mantro GmbH"></a>
38+
<a href="https://www.algolia.com/"><img src="https://mobx.js.org/docs/assets/algolia.jpg" align="center" width="100" title="Algolia" alt="Algolia" /></a>
39+
<a href="https://talentplot.com/"><img src="https://mobx.js.org/docs/assets/talentplot.png" align="center" width="100" title="talentplot" alt="talentplot"></a>
40+
<a href="https://careers.dazn.com/"><img src="https://mobx.js.org/docs/assets/dazn.png" align="center" width="100" title="DAZN" alt="DAZN"></a>
41+
<a href="https://blokt.com/"><img src="https://mobx.js.org/docs/assets/blokt.jpg" align="center" width="100" title="Blokt" alt="Blokt"/></a>
4242

4343
---
4444

@@ -131,7 +131,7 @@ depends on the `timer.secondsPassed` observable, even though this relationship i
131131
Every event (`onClick` / `setInterval`) invokes an _action_ (`myTimer.increase` / `myTimer.reset`) that updates _observable state_ (`myTimer.secondsPassed`).
132132
Changes in the observable state are propagated precisely to all _computations_ and _side effects_ (`TimerView`) that depend on the changes being made.
133133

134-
<img alt="MobX unidirectional flow" src="docs/assets/flow2.png" align="center" />
134+
<img alt="MobX unidirectional flow" src="https://mobx.js.org/docs/assets/flow2.png" align="center" />
135135

136136
This conceptual picture can be applied to the above example, or any other application using MobX.
137137

@@ -160,7 +160,7 @@ The philosophy and benefits of the mental model provided by MobX are also descri
160160

161161
### The MobX book
162162

163-
[<img src="docs/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+
[<img src="https://mobx.js.org/docs/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)
164164

165165
Created by [Pavan Podila](https://twitter.com/pavanpodila) and [Michel Weststrate](https://twitter.com/mweststrate).
166166

docs/actions.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ MobX requires that you declare your actions, although [`makeAutoObservable`](obs
2222

2323
2. By default, it is not allowed to change the state outside of actions. This helps to clearly identify in your code base where the state updates happen.
2424

25-
The `action` annotation should only be used on functions that intend to _modify_ the state. Functions that derive information (performing lookups or filtering data) should _not_ be marked as actions, to allow MobX to track their invocations.
25+
The `action` annotation should only be used on functions that intend to _modify_ the state. Functions that derive information (performing lookups or filtering data) should _not_ be marked as actions, to allow MobX to track their invocations. `action` annotated members will be non-enumerable.
2626

2727
## Examples
2828

@@ -258,19 +258,16 @@ class Store {
258258
fetchProjects() {
259259
this.githubProjects = []
260260
this.state = "pending"
261-
fetchGithubProjectsSomehow().then(
262-
this.projectsFetchSuccess,
263-
this.projectsFetchFailure
264-
)
261+
fetchGithubProjectsSomehow().then(this.projectsFetchSuccess, this.projectsFetchFailure)
265262
}
266263

267-
projectsFetchSuccess = (projects) => {
264+
projectsFetchSuccess = projects => {
268265
const filteredProjects = somePreprocessing(projects)
269266
this.githubProjects = filteredProjects
270267
this.state = "done"
271268
}
272269

273-
projectsFetchFailure = (error) => {
270+
projectsFetchFailure = error => {
274271
this.state = "error"
275272
}
276273
}
@@ -373,7 +370,7 @@ Note that the `flowResult` function is only needed when using TypeScript.
373370
Since decorating a method with `flow`, it will wrap the returned generator in a promise.
374371
However, TypeScript isn't aware of that transformation, so `flowResult` will make sure that TypeScript is aware of that type change.
375372

376-
`makeAutoObservable` and friends will automatically infer generators to be `flow`s.
373+
`makeAutoObservable` and friends will automatically infer generators to be `flow`s. `flow` annotated members will be non-enumerable.
377374

378375
<details id="flow-wrap"><summary>{🚀} **Note:** using flow on object fields<a href="#flow-wrap" class="tip-anchor"></a></summary>
379376
`flow`, like `action`, can be used to wrap functions directly. The above example could also have been written as follows:

docs/observable-state.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ The above APIs take an optional `options` argument which is an object that suppo
237237
- `autoBind: true` automatically binds all created actions to the instance.
238238
- `deep: false` uses `observable.ref` by default, rather than `observable` to create new observable members.
239239
- `name: <string>` gives the object a debug name that is printed in error messages and reflection APIs.
240+
- `proxy: false` skips Proxy creating. This is a good option if the shape of the object will not change over time, as non-proxied objects are easier to debug and faster. See [avoiding proxies](#avoid-proxies).
240241

241242
## Converting observables back to vanilla JavaScript collections
242243

0 commit comments

Comments
 (0)