vuex-easy-firestore
vuex-easy-firestore copied to clipboard
Disable synchronization
Hello, I'm eventually trying out the library, thanks for your work! I have a list of feedback for later, but this is my actual first question :)
In my app, I don't sync the store at all until the user has signed up. What is the recommended way to to tell the library to not attempt any kind of sync until then? Thank you!
@louisameline heyyy I'd recommend firebase Auth anonymous users. These are great because you can upgrade them later and the user won't loose their data ! ;)
Orrr don't initialise Firebase yet ? But actually I never tried this so I'm not sure I have good advice. I'd need to sit down and think about this can be done.
Thanks for the quick answer!
Free users have their data saved on the device only, I tell them to upgrade to have it saved in the cloud ;) Also I do not not want to pay Firestore fees for free users, so I will need an on/off switch.
As a sidenote, I need to finish a first version of my app, then help you as much as I can with this library. I think it has the right approach and should be the default choice for anyone using Vuex and Firestore. I'll discuss more when I open a bunch of issues to share ideas :) Thank you
I did it this way ...
Firebase.auth().onAuthStateChanged(user => {
if (user) {
store.commit('module/openDBChannel')
} else {
store.commit('module/closeDBChannel')
}
})
@scriptPilot even though the DB is closed, set
, insert
, patch
are still executed via the Firestore SDK as well.
This is because openDBChannel is only about "reading" data, not writing.
@louisameline I guess I could make a simple action you can dispatch to stop and start writing data.
Sent with GitHawk
I came to the same conclusion: an action, which makes it possible to enable certain modules (say the user's personal informations) while others stay inactive (say some data backupper). I think a module option to make the module inactive at startup until explicit activation will be needed as well.
@louisameline How did you eventually solve this? I'm looking for the same right now:
- Unregistered user => Store locally only
- Registered user => Use firestore
I have a function that calls the vuex methods directly instead of easy-firestore if the user is not logged in.