How can I trigger an event in one component using an event from another? I have two child components at the same level, and when the updated() method is called in component1.vue, I want the setValues() method in component2.vue to be triggered.
In component2.vue, this is what I currently have within the created hook:
created() {
EventBus.$on('updatedComponent', () => {
this.setValues();
});
}
And in the updated() method of component1.vue:
EventBus.$emit('updatedComponent');
I have already imported the event bus in both components, and it seems to work (I tested with a console log inside the $on) but the events are still not triggering. Do I need to place my EventBus.$on in a different lifecycle hook?