I am facing a challenge with my Vuex
store, as it imports the notifications.js
module that requires access to Vuex.store.state
. How can I resolve this issue?
Currently, I am passing store.state
as a prop to address the circular dependency. Is there a more effective solution available?
The current workaround involves importing store.state
in every file utilizing new Notification()
, just for the purpose of passing it as a prop.
Vuex store
import Notification from './notifications.js'
actions: {
someAction (store) {
new Notification({
name: 'notificationName',
state: store.state
})
}
}
notifications.js
// The direct import of Vuex store leads to a circular dependency
// import store from './store.js'
class Notification {
// Relies on store.state to function properly
}