Geniric Event Handler.
<script src="<module-dir>/lib/WebModule.js"></script>
<script src="<module-dir>/lib/EventHandler.js"></script>
<script>
function a1(event) {
console.log("call a1. detail: " + JSON.stringify(event.detail));
}
function a2(event) {
console.log("call a2. detail: " + JSON.stringify(event.detail));
}
var event = new EventHandler(["type-a", "type-b"]);
event.on("type-a", a1);
event.on("type-a", a2);
event.fire("type-a", { foo: 1 });
event.clear();
</script>
importScripts("<module-dir>lib/WebModule.js");
importScripts("<module-dir>lib/EventHandler.js");
...
require("<module-dir>lib/WebModule.js");
require("<module-dir>lib/EventHandler.js");
...