tl-events
v1.0.1
Published
eventBus
Downloads
8
Readme
1.安装tl-events
npm i tl-events
yarn add tl-events
2.使用tl-events
const eventBus = require("tl-events");
const event = new eventBus();
3.on emit的使用
const fn = (data) => {
console.log(data);
};
event.on("test", fn); // 监听
event.emit("test", "hello tl-events"); // 使用
4.off once
1.off 删除监听
2.once 只监听一次
event.off("test", fn); 删除的时候函数必须一致
event.once("test", fn);
5.tl-events 一个函数只监听10个否则会报错 但是可以设置
evnet.getMaxListeners // 10 默认是10
event.setMaxListeners(20)
evnet.getMaxListeners // 20