6

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?

jkdev
  • 11,360
  • 15
  • 54
  • 77
Yaron Levi
  • 12,535
  • 16
  • 69
  • 118

1 Answers1

6

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.

Brandon
  • 38,310
  • 8
  • 82
  • 87
  • But MobX also helps me when I append post to my observable array of posts. The array of posts is being "mutated". – Yaron Levi Aug 02 '16 at 21:36
  • 1
    Right you can use it for that just fine. But if that's all you are using it for, there's lots of other options that work just as well. In fact, for append only data models, there may even be more efficient solutions built for that particular data model. Mobx strengths really come into play if you are mutating the individual objects. It's just a relative thing – Brandon Aug 03 '16 at 01:00