I have two separate Vue components that need to talk to each other via an eventbus. Like:
form-component.Vue
import events from './events'
export default {
...
methods() {
sumbitForm() {
events.$emit('form-submitted', data)
}
}
...
}
other-component.Vue
import events from './events'
export default {
....
mounted() {
events.$on('form-submitted, data => {
this.list.push(data);
}
},
data() {
return {
list: []
}
}
....
}
But when the event is listened to 'this' is not referring to 'other-component' but to the actual eventbus 'events'.
How would I go about this problem?