vuex-easy-firestore icon indicating copy to clipboard operation
vuex-easy-firestore copied to clipboard

Disable synchronization

Open louisameline opened this issue 5 years ago • 7 comments

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 avatar Nov 14 '19 13:11 louisameline

@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.

mesqueeb avatar Nov 14 '19 14:11 mesqueeb

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

louisameline avatar Nov 14 '19 16:11 louisameline

I did it this way ...

Firebase.auth().onAuthStateChanged(user => {
  if (user) {
    store.commit('module/openDBChannel')
  } else {
    store.commit('module/closeDBChannel')
  }
})

scriptPilot avatar Nov 17 '19 01:11 scriptPilot

@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

mesqueeb avatar Nov 17 '19 01:11 mesqueeb

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 avatar Nov 17 '19 17:11 louisameline

@louisameline How did you eventually solve this? I'm looking for the same right now:

  1. Unregistered user => Store locally only
  2. Registered user => Use firestore

Gnopps avatar May 20 '21 07:05 Gnopps

I have a function that calls the vuex methods directly instead of easy-firestore if the user is not logged in.

louisameline avatar May 20 '21 07:05 louisameline