I am wondering if the realtime listener for Firestore supports async await instead of promise?
The documentation suggests:
var unsubscribe = db.collection("cities").where("state", "==", "CA").onSnapshot(function(querySnapshot) {
var cities = [];
querySnapshot.forEach(function(doc) {
cities.push(doc.data().name);
});
console.log("Current cities in CA: ", cities.join(", "));
});
unsubscribe();
Could I write the above realtime listener using async await? I tried the following and the listener does not work anymore. Also, it won't be possible to detach the listener anymore.
var querySnapshot = db.collection("cities").where("state", "==", "CA").onSnapshot
var cities = [];
querySnapshot.forEach(function(doc) {
cities.push(doc.data().name);
});
console.log("Current cities in CA: ", cities.join(", "));
How could I write it using async await and would be able to use the detacher as well?