A
A
Andrey2019-09-05 23:54:40
JavaScript
Andrey, 2019-09-05 23:54:40

Mobx: how to work with denormalized data?

I haven't used Mobx yet and I want to make a small project to get acquainted with it. I read the documentation for both Mobx and mobx-state-tree. And there is one misunderstanding.
The documentation says:

"Each domain object should be expressed using its own class (or constructor function). It is recommended to store your data in denormalized form. There is no need to treat your client-side application state as some kind of database. Real references, cyclic data structures and instance methods are powerful concepts in JavaScript."

That is, a direct recommendation not to use data normalization. But do not duplicate them, but use links. Like, it's a powerful concept. And how then to delete the data? For example, I want to delete a user, but I have no idea how many objects in the store refer to this user. This means that after deletion, the user will remain, some elements will refer to him, and he will continue his "life" in the application.
Moreover, on the same page it is written that mobx-state-tree is a more thoughtful solution. And in the mobx-state-tree, the data is essentially normalized, types.reference seems to hint at this.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question