Update
This commit is contained in:
parent
006fac7c97
commit
a30e5affaf
18
mobx.md
18
mobx.md
|
@ -11,6 +11,7 @@ import {observable, computed} from 'mobx'
|
||||||
class Page {
|
class Page {
|
||||||
@observable title = ''
|
@observable title = ''
|
||||||
@observable published = false
|
@observable published = false
|
||||||
|
@observable author = null
|
||||||
|
|
||||||
@computed get authorName () {
|
@computed get authorName () {
|
||||||
return this.author || 'Anonymous'
|
return this.author || 'Anonymous'
|
||||||
|
@ -71,6 +72,23 @@ class Foo {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### expr()
|
||||||
|
|
||||||
|
```js
|
||||||
|
// A temporary computed value. Its result is cached.
|
||||||
|
render () {
|
||||||
|
const isPublished = expr(() => page.published === true)
|
||||||
|
if (isPublished) { ... }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## [Modifiers](http://mobxjs.github.io/mobx/refguide/modifiers.html)
|
||||||
|
|
||||||
|
- `asMap(obj)` - JS map (dynamic keys)
|
||||||
|
- `asReference(fn)` - don't observe me
|
||||||
|
- `asStructure(obj)` - JS object (observe as deepEqual)
|
||||||
|
- `asFlat(array)` - JS array (observe its children)
|
||||||
|
|
||||||
## React
|
## React
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|
Loading…
Reference in New Issue