Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I store all the data in vuex state

Tags:

vue.js

vuex

If I use Vuex, is that means it's better to store every data in the vuex/state? I have a little confused, some data I get from API (for example UserDetail), I don't need it be shared in components or I counld easily pass it as props. Should I keep that kind of data in Vuex/State? Why not get the data by Promise or only use Vuex/Action/Promise?

like image 425
EasonBlack Avatar asked May 05 '17 09:05

EasonBlack


People also ask

Should I store all data in Vuex?

If you really need to have the data stored somewhere (vuex or components) it will have to use memory space anyway. I prefer using Vuex for large applications since it allows me to compartmentalize the data and have it structured in a way that is easier to understand and more organized.

How much data can you store in Vuex?

store can exceed 500-1000 objects and each of them can have 10-20-30 corresponding images.

Is Vuex cached?

Vuex allows us to define "getters" in the store. You can think of them as computed properties for stores. As of Vue 3.0, the getter's result is not cached as the computed property does.


1 Answers

Data should be kept as local as possible. That's a general principle that helps reduce complexity. Vuex should handle data that needs to be shared among not-closely-related components.

like image 175
Roy J Avatar answered Oct 27 '22 19:10

Roy J