on
on
works in place of firestore onSnapshot
but with the same syntax as the sweetened get
.
listen for doc changes
const unsubscribe = db.on("users", (docs) => {
for(const user of docs){
console.log(`${user.name} : ${user.age}`)
}
})
// equivalent firestore
const unsubscribe = fb.onSnapShot("users", (docs) => {
docs.forEach((ss) => {
const user = ss.data()
console.log(`${user.name} : ${user.age}`)
}
})
onK
andonS
return the same values asgetK
andgetS
respectively.