vuex-easy-firestore
vuex-easy-firestore copied to clipboard
[documentation] clarify how to set the config
Hi 👋,
Great module! really want to start using it, however I am struggling to see how to connect this to my own firestore account. Can you clarify in the documentation (or this issue) how to do this?
Happy to write the corresponding documentation for it :)
Best, D
Hi! This part of the documentation could definitely use some improvement.
This is how I usually do it:
// enable firestore with persistence
async function getFirestore () {
const firestore = Firebase.firestore()
firestore.settings({timestampsInSnapshots: true})
try {
await firestore.enablePersistence()
} catch (err) {
console.log('err.code → ', err.code)
if (err.code === 'failed-precondition') {
// Multiple tabs open, persistence can only be enabled in one tab at a a time.
let message = store.getters.text.api['firebase/failed-precondition']
notify({message, preset: 'error'})
} else if (err.code === 'unimplemented') {
// The current browser does not support all of the
// features required to enable persistence
return firestore
}
}
return firestore
}
// =========>
// Start Firebase
// =========>
Firebase.initializeApp(firebaseConfig)
Firebase.auth().onAuthStateChanged(user => {
getFirestore().then(db => {
if (user) {
// Signed in. Let Vuex Easy Firestore know.
store.dispatch('module/path/openDBChannel') // open the DB channels
} else {
// Signed out. Let Vuex know.
store.dispatch('resetStore', null)
}
})
})
Vuex Easy Firestore was made with ♥ by Luca Ban.
If this library helped you in any way you can support me by buying me a cup of coffee.
@DarylRodrigo Did it work out for you?
Let me know where you're stuck! It's important to know so I know how to best improve the documentation.
I think the documentation just needs a step in the setup explaining where to put the firestore config and in which file the connection should be initiated.
I usually initialize my firebase app in another js file and then import that into whatever component I'm accessing the store in.
After about two years of open source, I finally got accepted for Github Sponsors!
💜 github.com/sponsors/mesqueeb 💜
A little about me:
- I love open-source
- 6 months ago I got a son, and am trying to be an awesome father 😅
- I'm doing freelance work here and there as my main job
If anyone was helped with vuex-easy-firestore, I'd greatly appreciate any support!
BTW, donations get's paid DOUBLE by GitHub! (they're alchemists... 🦾)
Going forward 👨🏼💻
- I got great plans for the future of vuex-easy-firestore going above and beyond!! Look forward to it!!
- On to many more years of open-sourcing! 🎉