MobX at WM

12/11/17

Why we chose it over Redux

MobX

What is MobX?

MobX is a battle tested library that makes state management simple and scalable by transparently applying functional reactive programming (TFRP)

Why do we use state management?

To lift state

Component State

  • Favor this as the first approach
  • Simple

Container Pattern

  • Simple for simple component trees
  • Simpler than state management library

Store Pattern / Shared State

  • Last resort
  • Uses Singletons
  • Components can be in different sub-trees

Bonus Points - Why is this bad?

It's shared mutable state!

Flux

We can solve this with Flux

Redux Flux

  • Describe your actions with an Action Creator

Redux Flux

  • Derive your new store shape in Reducer

Redux Flux

  • connect() to your component

MobX Flux

  • Describe store
  • with "state"
  • and Actions (action creators)

MobX Flux

  • observe your store (connect)

Why MobX?

Complexity

  • Flux and Redux/Mobx try and solve global state.
  • How much of this state is global?
  • YAGNI

Familarity

  • Similar to enough to Angular Services for a warm fuzzy

Boilerplate

  • Bytes down the wire
  • Less files in MobX

Downsides

  • Devtools are not as good
  • Community Support not as good
  • Going full FRP can get academic and irritating (same with Redux purity)

Questions / Comments?

MobX at WM

By Charles King

MobX at WM

Why we chose it over Redux

  • 598