Comments (4)
Dear David Piesse,
Thank you for your comment!
In line with my vuex plugins:
- vuex-easy-access
- vuex-easy-firestore (this one)
I'm currently working on a vuex-easy-firebase-auth plugin to easily setup the firebase authentication and have it saved in a vuex user
module.
However, that package needs some more time until it's ready for beta release. : S
I do think that maybe I need some better documentation here as well for how to enable the firestore.
For now you I'll share you how I personally do it in my projects:
// 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)
}
})
})
from vuex-easy-firestore.
Awesome!
Thanks for spending the time with a full reply; I look forward to the next package!
I had a play last night and I had a simpler version of your method; which is great as I know am on the right path.
from vuex-easy-firestore.
@davidpiesse No problem!
Let me know if you are able to use this package well or run into any problems! I'll try help out as much as I can!
For now this plugin works for me. (However, I still need to add tests, but having trouble finding a good Firestore mock for testing...)
It's crucial to not forget to open the DB channel: dispatch('module/path/openDBChannel')
Please note I haven't tested when a user logs out and a different user logs in yet. I need to finish auto re-freshing the vuex store in that case, so for now you'd have to do something like dispatch('resetStore')
and write this yourself. Just empty out the prop where you save your docs should be fine.
I'm still working on perfecting the integration with vuex-easy-access
have a look at that library as well and let me know what you think : D
from vuex-easy-firestore.
Will do.
I'll open issues if I find things but just because it's an easy way to communicate on these things.
I'll try and push fixes if I can 😁
from vuex-easy-firestore.
Related Issues (20)
- cannot read resolve of undefined HOT 7
- Feature: Add firestore.getAll() on the web HOT 7
- Question: can we rely on the `signedIn` getter to check if the user is signed in? HOT 3
- Guard 'id' will still add 'id' on update HOT 1
- Reacting to changes in vue-router HOT 1
- Retrieve subcollections together with document HOT 2
- feat(docs): add firestore guide
- RangeError: Maximum call stack size exceeded HOT 6
- ProjectId not provided in firebase.initializeApp despite being provided HOT 3
- Can't get it to work no matter what! HOT 6
- Two-way binding HOT 4
- Getters undefined when working with users collection + sign in onAuthStateChanged [Help]
- fetch only returns id in doc HOT 2
- Update library for firebase v9 HOT 3
- Adding "in" or "array-contains" to the where clause
- setPathVars should be better documented HOT 1
- Doc insertion from multiple apps at he same index
- project build process HOT 1
- E2E test with Cypress
- syncStack / rejects HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuex-easy-firestore.