small-event-bus
v1.0.2
Published
事件订阅发布中心
Readme
简介
小巧简单的事件发布订阅中心
使用
- 安装
npm install small-event-bus- 使用
//订阅事件
import smallEventBus from "./index.js";
function aHander(arg) {
console.log("订阅事件接受的参数", arg);
return "aHander Done";
}
smallEventBus.subScrible("a", aHander);
//发布事件
const callBackData = smallEventBus.public("a", {
name: "test",
desc: "测试数据",
});
console.log("发布后返回的参数", callBackData);api
| 方法 | 描述 | | :------------- | :------- | | subScrible | 订阅 | | subScribleOnce | 单次订阅 | | public | 发布 | | unSubscrible | 取消订阅 |
