You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -106,26 +107,22 @@ So what does code that uses MobX look like?
106
107
importReactfrom"react"
107
108
importReactDOMfrom"react-dom"
108
109
import { makeAutoObservable } from"mobx"
109
-
import { observer } from"mobx-react"
110
+
import { observer } from"mobx-react-lite"
110
111
111
112
// Model the application state.
112
-
classTimer {
113
-
secondsPassed =0
114
-
115
-
constructor() {
116
-
makeAutoObservable(this)
117
-
}
118
-
119
-
increase() {
120
-
this.secondsPassed+=1
121
-
}
122
-
123
-
reset() {
124
-
this.secondsPassed=0
125
-
}
113
+
functioncreateTimer() {
114
+
returnmakeAutoObservable({
115
+
secondsPassed:0,
116
+
increase() {
117
+
this.secondsPassed+=1
118
+
},
119
+
reset() {
120
+
this.secondsPassed=0
121
+
}
122
+
})
126
123
}
127
124
128
-
constmyTimer=newTimer()
125
+
constmyTimer=createTimer()
129
126
130
127
// Build a "user interface" that uses the observable state.
131
128
constTimerView=observer(({ timer }) => (
@@ -178,7 +175,6 @@ The **[MobX Quick Start Guide](https://www.packtpub.com/product/mobx-quick-start
178
175
-[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
176
- {🚀} [React Live 2019: Reinventing MobX](https://www.youtube.com/watch?v=P_WqKZxpX8g) by Max Gallo, _27 min_.
180
177
181
-
182
178
## Credits
183
179
184
180
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.
0 commit comments