Closed
Description
What problem is this solving
Firebase recently introduced the modular web SDK, currently in beta.
One of its goals is to reduce the footprint of the lib allowing tree shaking. Therefore, a lot of users might want to benefit from using it.
Using vuexfire does currently not seem to be working with the new Firebase modular SDK because of the changed API:
TypeError: document.onSnapshot is not a function
at bindDocument (webpack-internal:///./node_modules/vuexfire/dist/vuexfire.esm.js:456)
at eval (webpack-internal:///./node_modules/vuexfire/dist/vuexfire.esm.js:614)
at new Promise (<anonymous>)
at bind$1 (webpack-internal:///./node_modules/vuexfire/dist/vuexfire.esm.js:603)
at bindFirestoreRef (webpack-internal:///./node_modules/vuexfire/dist/vuexfire.esm.js:655)
See here for the new way the API works. What used to be something like this:
db.collection("cities").doc("SF")
.onSnapshot((doc) => {
console.log("Current data: ", doc.data());
});
...is now something like this:
import { doc, onSnapshot } from "firebase/firestore";
const unsub = onSnapshot(doc(db, "cities", "SF"), (doc) => {
console.log("Current data: ", doc.data());
});
That's why I think the bindFirestoreRef(...)
now needs to be adjusted to adjust to the new API.
Proposed solution
As version 9 of the Firebase JS SDK will be the modular one, adjust to the new API so that vuefire/vuexfire works with the Firebase 9 JS SDK.
Describe alternatives you've considered
Stick with Version 8 of the Firebase JS SDK for now.