I have list of components which changes Vuex state after click. And i want to render difference between two Vuex state values: before and after action dispatched from click handler.
It could be something like that:
<template>
<ul>
<li v-for="item of items" @click="clickItem">{{difference}}</li>
</ul>
</template>
<script>
export default {
methods: {
difference() {
let oldValue = this.$store.getters.getValue();
this.$store.dispatch(SOME_ACTION);
let newValue = this.$store.getters.getValue();
this.$store.dispatch(UNDO_SOME_CATION);
return newValue-oldValue;
}
clickItem() {
this.$store.dispatch(SOME_ACTION);
}
}
}
</script>
But the problem is that this code produce infinite rendering loop because action dispatching changes Vuex store and Vuex reactivity in turn triggering app components rerendering.
Is there any possibility disable Vuex reactivity than dispatch action, get new value, than dispatch undo action and enable reactivity? If yes, it could solve my problem.