- MobX Quick Start Guide
- Pavan Podila Michel Weststrate
- 128字
- 2021-08-05 10:34:26
Summary
The story of MobX revolves around observables. Actions mutate these observables. Derivations and Reactions observe and react to changes to these observables. Observables, actions, and reactions form the core triad.
We have seen several ways to shape your observables with objects, arrays, maps, and boxed observables. Actions are the recommended way to modify observables. They add to the vocabulary of operations and boost performance by minimizing change notifications. Reactions are the observers that react to changes in observables. They are the ones causing side-effects in the app.
Reactions come in three flavors, autorun(), reaction(), and when(), and distinguish themselves as being long-running or one-time. when(), the only one-time effector, comes in a simpler form, where it can return a promise, given a predicate function.