Sorry if I missed something; I searched all the closed issues and similar ones deal with updates to arrays; in my case it's a scalar. Also this is my first Vue/Vuex project so please educate me if I'm not doing things the right™ way.
I have a store with a state:
js
const state = {
currentAircraft: null,
//[...]
};
getters:
`js
// [...]
currentAircraft: state => state.aircraft
actions:
js
// [...]
setCurrentAircraft({commit}, {registration}) {
return new Promise((resolve, reject) => {
commit(types.SET_AIRCRAFT, {registration});
resolve();
});
},
and mutations:
js
// [...]
[types.SET_AIRCRAFT](state, {registration}) {
state.currentAircraft = registration;
state.allFlights = [];
},
// [...]
and I have a component that uses the action and compares it to a property using a computed property:
js
export default {
props: ['aircraft'],
computed: {
...mapGetters(['currentAircraft']),
isActive() {
console.debug(this.currentAircraft, this.aircraft);
return this.currentAircraft === this.aircraft;
}
},
methods: {
...mapActions(['setCurrentAircraft', 'getAllFlights']),
showAircraft() {
this.setCurrentAircraft({registration: this.aircraft}).then(() => this.getAllFlights());
}
}
}
The problem is that after calling the showAircraft() action, the computed property is not re-computed. Any tips on how to find the issue?
Lol, it's important that your getter correctly poll the right state variable 🤦♂️
Most helpful comment
Lol, it's important that your getter correctly poll the right state variable 🤦♂️