nitem
v1.0.2
Published
js 事件总线
Downloads
2
Readme
nitem
介绍
js 事件总线
软件架构
软件架构说明
Nitem
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 Nitem from "nitem";
Usage
import Nitem from "nitem";
const nitem = new Nitem();
//监听 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();