1//Listen for the event
2window.addEventListener("MyEventType", function(evt) {
3 alert(evt.detail);
4}, false);
5
6//Dispatch an event
7var evt = new CustomEvent("MyEventType", {detail: "Any Object Here"});
8window.dispatchEvent(evt);
1const event = new Event('build');
2
3// Listen for the event.
4elem.addEventListener('build', function (e) { /* ... */ }, false);
5
6// Dispatch the event.
7elem.dispatchEvent(event);