Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why MobX is less suitable for applications that have an append only domain model?

Tags:

reactjs

mobx

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?

like image 688
Yaron Levi Avatar asked Aug 01 '16 13:08

Yaron Levi


People also ask

Does MobX work with functional components?

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.

Is MobX scalable?

MobX a simple, scalable state management.

Is MobX slow?

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.

What is the use of MobX in ReactJS?

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.


Video Answer


1 Answers

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.

like image 164
Brandon Avatar answered Nov 13 '22 09:11

Brandon