/2020-events

事件分发器(同步)

Primary LanguageJavaScript

Build Status

安装

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));