light-event-lib
TypeScript icon, indicating that this package has built-in type declarations

1.3.3 • Public • Published

说明

观察者模式,提供事件广播

使用本库

1. 安装
npm install light-event-lib
2. 使用具体说明
2.1 引用
import lightEvent from "light-event-lib";
2.2 广播信息
this.listener.emit<string>("LISTENER_TEST", "hello npm event lib");
2.3 注册处理
注册:
    this.listener.on("LISTENER_TEST", this.onListenerHandler, this);

处理:
    private onListenerHandler(e: lightEvent.LightEvent<string>): void {
        switch (e.eventType) {
            case "LISTENER_TEST":
                console.log(e.data);
                break;
        }
    }

Readme

Keywords

Package Sidebar

Install

npm i light-event-lib

Weekly Downloads

4

Version

1.3.3

License

ISC

Unpacked Size

9.25 kB

Total Files

6

Last publish

Collaborators

  • aonaufly