I have a namespaced vuex store that returns an entry of the store based on the parameter of the current route.
import Router from '../../router/index'
const options = {
routeIdentifier: 'stepId'
}
export function fromRoute(state) {
if (!options.routeIdentifier || !Router.currentRoute.params) {
return null
}
return state.all.find(element => {
return element.identifier === Router.currentRoute.params[options.routeIdentifier]
})
}
This works as expected for the initial load. However, it is not reloaded whenever the route changes.
Is there a way to reload / force the recalculation of the getter on change of the route?
beforeEach
to set the current route in the store? – Pomegranaterouter.currentRoute._rawValue.params
works in newer versions. – Shirk