In a Vue 3 app, I am referencing store getter and watching the change in its value to do some logic.
I need to compare the old and new values. However, I am getting the same values for each argument passed to the watch function.
Here is my setup:
<script>
import { useStore } from 'vuex'
import { watch } from 'vue'
export default {
setup() {
const store = useStore()
let text = store.getters['SOME_ARRAY']
watch(text, (text, prevText) => {
console.log(text.length, prevText.length)
})
}
return { text }
}
</script>
In the console.log both lenghts are the same (ie, 3 3, 4 4, 5 5...).