Create and dispatch custom events.
Source Code
let event = new CustomEvent('myEvent', { detail: { message: 'Hello' } });
document.dispatchEvent(event);
document.addEventListener('myEvent', function(e) {
console.log(e.detail.message); // 'Hello'
});