安装
npm i gs-events --save-dev
文档
基本用法
import { Event, EventDispatcher } from "gs-events";
class Node extends EventDispatcher {
constructor() {
super();
this.addEventListener("custom", this.handler);
}
handler( evt ) {
console.log("scope:", this);
console.log("event:", evt);
}
}
let node = new Node();
node.dispatchEvent(new Event("custom", false, true));