[Vuejs]-Vuejs shows the same data on multiple components

0👍

Okay I’ve found what caused this behaviour: there is a computed property in the component, which monitors this.$store.getters.authStatus == "received" state. Since ALL component instances monitor this single state, when it changes, ALL component instances will be updated.
A possible fix is to send some component specific data (title, id, etc.) along this.$store.dispatch(‘getsensordata’, data) request which will be replied back to all component instances, but only one component will be updated:

computed: {
setSeries() {
  if(this.$store.getters.authStatus == "received") {

    // Filter down to our chart otherwise all charts will be updated!
    if(this.header.title == this.$store.getters.getData.header.title && this.parameterdata.pidx == this.$store.getters.getData.header.pidx) {
      this.s1 = _.cloneDeep(this.$store.getters.getData.data);         
      }
  }
  return this.s1;
}

}

Leave a comment