[Vuejs]-How to reload dom elements on Firestore db change?

0👍

It looks like VueFire is not making another call to the database when the activeRestaurantId is changed. You can re-write this code in a method to update when that variable changes like so:

data () {
  return {
    'regularItems': []
  }
}
methods: {
  updateActiveRestaurant () {
    db.collection('items').where("restaurant", "==", this.userAccount.activeRestaurant.id)
    .get()
    .then(function (querySnapshot) {
      querySnapshot.forEach(function (doc) {
        var item = doc.data()
        item.id = doc.id
        this.regularItems.push(item)
      }.bind(this))
    }.bind(this))
  }
}

And then you can add a call to this function on created and after the activeRestaurant data changes.

Leave a comment