events-await
v0.2.0
Published
eventEmitter async await version
Downloads
1
Maintainers
Readme
支持异步的事件发射器
使用
promise
import { AsyncEventEmitter } from "events-await";
const e = new AsyncEventEmitter();
e.on("touch", async (param) => {
console.log("touch event", param);
});
e
.emit("touch", "param1")
.then(() => {
e.emit("touch", "param2");
});
// touch event param1
// touch event param2
async
import { AsyncEventEmitter } from "events-await";
const e = new AsyncEventEmitter();
e.on("touch", async (param) => {
console.log("touch event", param);
});
async function test() {
await e.emit("touch", "param1") // touch event param1
await e.emit("touch", "param2") // touch event param2
}
test()