Closed l2aelba closed 4 years ago
I got a better solution, use state instead.
createEasyFirestore({
firestorePath: 'items',
firestoreRefType: 'collection',
moduleName: 'items',
state: state.storage.items // This is from JSON.parse(localStorage.getItem('myApp'))
})
But this is right way to do?
Hi, I personnaly use vuex-persist to populate from localstorage, it works like a charm out of the box.
And I think the state
property that you mentioned should be reserved for the default blank state, and not used to populate with actual data retrieved from localstorage. Because when the whole store is reset (typically at logout), we need to know what the blank state is. So if you don't use vuex-persist, you should populate the state with regular vuex actions instead. @mesqueeb do you confirm?
@l2aelba
defaultValues
is only for "collections" where the document are "loaded" async when you do openDBChannel
or fetchAndAdd
, then every incoming doc is merged onto the default values.
This feature is therefore something different from what you are looking for.
I see nothing wrong with defining the state like you do directly from local storage. Vuex Easy Firestore is able to work with that state just like regular docs that are fetched, it won't even know the difference. Which is OK if this is what you want. ; )
--
Vuex Easy Firestore was made with ♥ by Luca Ban.
If you use this library in your projects, you can support the maintenance of this library by a small contribution via Github 💜.
You can also reach out on twitter if you want a one-on-one coding review/lesson. 🦜
Thank you guys :D
Right, state
is for doc mode! So my advice not to use it for that purpose applies in doc mode of course, not collections.
I want to get data from local storage to render the list ASAP and get real/updated data after.
Any trick I can do?
PS: Using local storage does not require. If something better please tell me
Still does not fast enough.