1.0.0 • Published 5 months ago

small-event-bus v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

简介

小巧简单的事件发布订阅中心

使用

  1. 安装
 npm install  small-event-bus
  1. 使用
//订阅事件
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取消订阅
1.0.0

5 months ago