MobX Intro
Unhappy with Redux? Try MobX!
Redux is awesome, but...
Too many boilerplates / rules
A lot of code
action, dispatch const, reducer...you need them when every simple job
You need learn more to make your project perfect
Smart / Dumb component
Immutable.js
redux-thunk
redux-saga
What is MobX
An Reactive Programing lib
Base on Observer patten
State managment, like redux, flux
Works perfect with React
Why MobX
No boilerplate or rule
just focus on your logic
Less code, less work
and go home earlier
Simple and scalable
you don’t need any mobx-*
How it works
How it works
observable()
autorun()
https://jsbin.com/batefip/1/edit?js,console
How it works
How it works
https://github.com/mobxjs/mobx/blob/gh-pages/docs/best/react.md
TL;DR: MobX reacts to any an existing observable property that is read during
the execution of a tracked function.
How it works
@observable
@computed
@action
autorun()
https://jsbin.com/vakedu/1/edit?js,console
Work with React
@observer
https://jsbin.com/pakabaqona/edit?js,output
Performance test
Todo MVC with 10,000 items
https://github.com/mweststrate/mobx-todomvc
https://github.com/mweststrate/redux-todomvc (optimized by Dan Abramov)
Performance test
Add 1 item
MobX: 148.1 + 284.1 + 17.9 = 450.1ms
Redux: 215.1 + 248.1 + 42.5 = 505.7ms
Performance test
Remove 1 item
MobX: 382.8 + 312.6 + 31.7 = 727.1ms
Redux: 307.5 + 537.4 + 79.4 = 924.3ms
Performance test
Change 1 item
MobX: 60.6 + 160.3 + 213.8 = 434.7ms
Redux: 140.2 + 149.3 + 261.0 = 550.5ms
MobX vs Redux
Pros
No boilerplates, very flexble
Less code
Simple and easy to learn
Easy to get high performance
MobX vs Redux
Cons
No best practice, depends on your ablity.
Too much freedom, you can do something great … or terrible.
Q & A
Thank you : ^ )
Unhappy with Redux? Try MobX!

MobX intro