Joel interviews Michel Weststrate, author of Mobx and his new library, Immer. Today they get into the power of Immer, its early success on Github, common mistakes in state management, and what is next for Mobx.
Immer is a light-weight, immutable state-management tool. Michel talks with Joel about some of its capabilities. Immer takes an object and a function and can track all the changes made to that object, it then gives you back the original object and a mutated copy. Immer can replace reducers, Michel calls them "producer" functions as they "produce" the new state.
Joel then asks Michel "what makes state management so hard for people and are they overcomplicating it?" This question leads to Michel explaining that people don't think enough about the structure of their state enough up front. When you talk about state, there are three distinct concepts, values, references, and identities. However, people tend to only think of state purely as data. "You have to think about what is going to store it and what is going to reference it."
Michel talks about how the mobx-state-tree fits into an application. Mobx is unopinionated; it doesn't tell you how to organize your stores. mobx-state-tree, however, is very explicit about the three concepts of state, values, references, and identities. With mobx-state-tree you organize your data into models and tell it how they relate to each other. It's all about consistently organizing your state!
What's next for Mobx? Michel is currently working on some exciting features using proxies to make Mobx even more transparent than it is now. Michel has also been thinking about improving on asynchronous processes and how to leverage async actionables.