async function listenDiffs()

in firestore/main/index.js [721:742]


async function listenDiffs(db, done) {
  // [START firestore_listen_query_changes]
  const observer = db.collection('cities').where('state', '==', 'CA')
    .onSnapshot(querySnapshot => {
      querySnapshot.docChanges().forEach(change => {
        if (change.type === 'added') {
          console.log('New city: ', change.doc.data());
        }
        if (change.type === 'modified') {
          console.log('Modified city: ', change.doc.data());
        }
        if (change.type === 'removed') {
          console.log('Removed city: ', change.doc.data());
        }
      });
      // [START_EXCLUDE silent]
      observer();
      done();
      // [END_EXCLUDE]
    });
  // [END firestore_listen_query_changes]
}