nitemei
v1.0.1
Published
js 事件总线
Downloads
1
Readme
nitem
介绍
js 事件总线
软件架构
软件架构说明
Nitemei
Table of Contents
Install
npm install nitem -S
Then with a module bundler like rollup or webpack, use as you would anything else:
//use ES6 Module
import Nitemei from "nitemei";
Usage
import Nitemei from "nitemei";
const nitem = new Nitemei();
//监听 load
nitem.on("load", function (res) {
console.log(res);
});
//发射 load 事件
nitem.emit("load", "加载完毕");
//监听和移除
function handle(res) {
console.log(res);
}
nitem.on("refresh", handle);
nitem.emit("refresh", "刷新了");
//移除 refresh 事件
nitem.off("refresh", handle);
nitem.emit("refresh", "刷新了");
//移除指定事件
nitem.clear(["abc", "load"]);
//移除所有 事件
nitem.clear();