The creator of MobX, Michel Westrate, said:
MobX is suitable for building any app that needs to perform CRUD like operations on the state model. It is less suitable for applications that have an append only domain model.
If I understood correctly, "append only domain model" may refer to apps which consist of feeds/lists of data that are being added continuously (Facebook for example).
What does he mean by "append only domain model" and why isn't MobX suited for it?
In this tutorial, we will learn how to use MobX with React Functional Components. MobX being a very useful state management library reduces the code that needs to be written for global state management. Mobx is easy to use and quick to learn.
MobX a simple, scalable state management.
MobX is very fast, often even faster than Redux, but here are some tips to get most out of React and MobX. Most apply to React in general and are not specific to MobX. Note that while it's good to be aware of these patterns, usually your application will be fast enough even if you don't worry about them at all.
MobX is a simple, scalable, boilerplate-free state management solution. It allows you to manage application state outside of any UI framework, making the code decoupled, portable and, above all, easy to test. It implements observable values, which are essentially using the publish/subscribe pattern.
Append only domain models don't ever mutate state. They just append new state. The strength of MobX is in its ability to "watch" state and react when it is mutated. But since you aren't mutating state (only appending) you lose out on a lot of that strength.
Its still useful: if you using MobX to watch "size" or "count" or something then you'll be reacting when those values change as state is appended. That's just not nearly as hard of a problem as concurrently watching 100's of state objects and reacting when any of them change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With