A collection of simple mobx examples. All the examples below have been written in ES5 without JSX. No transpiling required. Please feel free to make any suggestions for improvement.
Baseline JSFiddle Includes: React, lodash, mobx, mobxReact, and mobxDevtools.
Baseline JSFiddle with decorators Includes: React, mobx, mobxReact. Thanks @spion!
Please note that I have created a console.log
override that prints the
console.log
s out to the results window on JSFiddle.
computed
Note how the computed fullName is cached.
-
action
Non-strict action usage. You may still set values outside of the actions. -
action strict mode
Strict action usage. OPEN YOUR CONSOLE. You should see an error where I try to set firstName directly. Note how easy it is to see the cause in the stack.
-
untracked
Compare with the normal computed example
-
Timer example Timer example heavily based on Patrick Klitzke's tutorial It's all about time: Building a performant Stopwatch with MobX and React - fast
-
Super cool MobX Redux tools example! Huge Thanks to @mdiordiev! See his project here for details: https://github.com/zalmoxisus/mobx-remotedev
-
The RED COBRA'S poker timer Beware of the Red Cobra! For his poker timer not only times blinds, it speaks!