Episode 17
The Magic Behind MobX
MobX is a state management library that's found popularity in the React community—it's often introduced as an alternative to Redux that's easier to work with and reason about, where things "just work". But what about it makes it easy to use?
For starters, it follows the Observable pattern—you break your domain into mutable state objects, observers (which map neatly to React components), and actions that only change one thing at once. But Observable libraries are nothing new, in fact it's the exact mental model people are familiar with from working with spreadsheet applications. As a result, a version of this pattern appears in virtually every JS UI framework, as well as Node itself. But MobX still feels like something new. It feels like magic.
In this episode, we'll look at the two core mechanics that underlie MobX's beauty—what makes it possible to provide such an "invisible" API. In order to do that, we'll build up the same API from scratch and look at how some lesser-known features of JavaScript itself make things so seamless.