📜  事件模块 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:24.700000             🧑  作者: Mango

代码示例1
const EventEmitter = require('events');
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});

const sym = Symbol('symbol');
myEE.on(sym, () => {});

console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]