I have a lwc that dispatches an event to be received by another lwc that's not in the same DOM tree.
This is my child lwc block of code:
this.dispatchEvent(new CustomEvent('newfilesuccess'));
And this is my listener lwc (not parent):
constructor(){
super();
this.addEventListener('newfilesuccess', this.handleFileSuccess);
}
handleFileSuccess = () => {
console.log('success!');
}
But I can't manage to handle communication between both lwcs. How can I achieve this?
Regards,