I would like to understand if using the store adds weight to the page, for example I use it to store various customer lists with relative images in base64 format.
If it should have weight on the page where can I check it (for example for the service worker I can view it in the appropriate tab in the google console)? Is there a limit? Is it always better to use local DBs like dexie?
list (or store.state.list) doesn’t really contain 1mln items.
the items are stored in your machine memory.
list (or store.state.list) contain only the address (ref) of the location in mem.
something like this (dummy):
That’s not a problem, because I need it to make the application run faster and when it goes offline.
The only inconvenient thing is that using it as a mini database is sometimes cumbersome, for example I have this structure:
(first category)
A -> b/c
(Second category which depends on the first)
b -> d/e
c -> f/g
(Third category)
d -> h/i
State structure:
state: {
firstCategory: [...] //array of object with data
secondCategory: [...] //array of object with data
thirdCategory: [...] //array of object with data
tempIdFirst: 1 //int of id selected (first)
tempIdSecond: 1 //int of id selected (first)
tempIdThird: 1 //int of id selected (first)
}
So if i need for example “i” data:
//in the router/page
store.dispatch('updateTempIdSecond', parseInt(id));
//in the store:
updateTempIdSecond( { state }, id) {
state.tempIdSecond= id;
},
//in the router/page
store.dispatch('updateTempIdThird', parseInt(id));
//in the store:
updateTempIdThird( { state }, id) {
state.tempIdThird= id;
},
And just then return it:
//store getters
retriveThird( { state }) {
return (some condition for see if exist the upper category) ?
state.thirdCategory[state.tempIdSecond]['thirdCategory'].find(el => el.tempIdThird === state.tempIdThird) : [];
}
Instead in dexie seems like more user friendly like:
db.thirdCategory.where("id").equals(id).toArray()
That will return directly the array or the empty array, basically I have to do one or two less operations.
But there are several limitations with that method like memory, some incompatibilities etc.
So it’s better use a filter directly instead of use getters in this case?
I really don’t understand why getters doesn’t have directly a parameter for filter into the function