Perhaps there's a misunderstanding on my part regarding the concept of a getter in Vuex. Let's consider a scenario where I have a getter that fetches the size of a DOM element, such as a div. The code would look something like this:
const getters = {
getContainerWidth (state) {
return document.getElementById('main-content').clientWidth;
}
}
Upon starting my application, all the getters are executed immediately. But what if the div is not available during startup? How can I re-run a getter?
Currently, I run the getter like this:
import store from '@/store'
store.getters['myModule/getContainerWidth']
I had a thought that maybe doing this would work:
store.getters['myModule/getContainerWidth']()
However, since store.getters is an object with properties and values that are not functions, it seems that I cannot re-run them.
Any suggestions or ideas?