alpheios-project / documentation

Alpheios Developer Documentation
0 stars 0 forks source link

Vuex data storage #36

Open kirlat opened 3 years ago

kirlat commented 3 years ago

The purpose of this issue is to gather and discuss the best practices of storing data in Vuex.

Vuex may have troubles tracking changes in objects that are nested too deeply or are stored in structures other than plain JS objects (like Arrays, Sets, Maps, etc.). The recommended practices at the moment are to keep the Vuex state data as flat as possible. In order to do that, complex structures has to be normalized: https://forum.vuejs.org/t/vuex-best-practices-for-complex-objects/10143/47.

I don't like that it makes data harder to read and, as @irina060981, mentioned, establishes relations between data pieces, with all the drawbacks. I, however, can accept it as a necessary evil for the lack of a better solution. One remedy might be to store data in some other format and have a function that will convert it to a format that is Vuex-friendly. This will allow to have data in its original format that is easier to read at the cost of data duplication: there will be two copies of data - one in the original format and another one in a Vuex-friendly one. But that's probably OK too.

@balmas, @irina060981: please share your thoughts and suggestions on the topic here. Thanks!