I'm working on implementing a vue event bus to facilitate event communication between my components. In my app.js
file, I have included the line
Vue.prototype.$eventBus = new Vue();
. Within one component, I trigger an event using:
this.$eventBus.$emit('pnc-person', remarkString);
Then, in a separate component, I handle the event within the mounted method like this:
this.$eventBus.$on('pnc-person', (data) => {
console.log(data);
});
Although the event is successfully emitted and visible in the vue dev tools, it is not being caught by the second component. I am utilizing vue router in this project, so I'm unsure if that may be influencing the situation.
I have experimented with both this.$route.$on
and this.$eventBus.$on
, but neither method appears to log anything.