MobX & MST
/
mail@hyunseob.me
State Management
1. MobX ? 🤔
⚡
" , ."
(observable)
MobX
observable
1 " "
render " "
render observable
2. MobX ✅
React ❌
State Management ❌
Redux ?
Easy to Use
👌
API
OOP,
TypeScript 💕
API
TypeScript 👍 ( )
3. 😖
Real Life Example )
:
..?
😔
Serialize / Deserialize
JSON observable
constructor assign
Deserialize 👿
Server Side Rendering 😣
🤦
😩
mobx serialize / deserialize
..
Store / Store
Singleton Pattern
Dependency Injection
API
Error Handling
...
4. MobX State Tree 🌳
, Redux VS MobX
Immutable
State
Pure Object
Serialize
Single Root Tree 🌳
/
Time Traveling ⏳
Redux MobX
Mutable
State 👌
Serialize
/ 💅
Time Traveling
MobX State Tree 🌳
MobX Redux
Single Tree 🌳
Mutable, But Immutable Snapshot
MobX ✅
MobX
Opinionated. .
☝
( )
TypeScript
PropTypes
🤔
Serialize / Deserialize
MobX ⭐⭐
!
observable
computed
action
MobX State Tree 🌳
Immutable ✅ (Snapshot)
State
Pure Object ✅ (Snapshot)
Serialize ✅
✅
Single Root Tree 🌳 ✅
✅
/
Time Traveling ⏳ ✅
Redux MobX
Mutable ✅
State 👌 ✅
✅
Serialize
✅
/ 💅 ✅
Time Traveling
Demo 👀
🎈
State Tree
,
observable
API
Reference ( )
Snapshot Immutable
Memoization (without reselect)
(redux-devtools, mobx-devtools, wiretab..)
( LocalStorage )
...
🙅
Magic ( )
MobX
( )
yield
When not to use MST?
"If you have a performance critical application that handles a
huge amount of mutable data, you will probably be better off by
using 'raw' MobX, which has a predictable and well-known
performance and much less overhead."
5. Practices
AppStore
UserStore NotificationStore PieStore InviteeStore ...
AppStore
UserStore NotificationStore PieStore ProjectStore ...
AdminStore
InviteeStore ActiveUserStore ...
View
Global
React State
LogInPage
LogInForm
isSubmitting
...
LogInPage
LogInForm
isSubmitting
...
LogInStore
id
Root
TodoStore UserStore
User
🙇
mail@hyunseob.me
github.com/hyunseob
twitter.com/hyunseob_

MobX & MST: 편안한 State Management