EventEmitter 类


EventEmitter 类由 events 模块定义:

const EventEmitter = require('events');

当新增监听器时,会触发 'newListener' 事件;当移除已存在的监听器时,则触发 'removeListener' 事件。

The EventEmitter class is defined and exposed by the events module:

const EventEmitter = require('events');

All EventEmitters emit the event 'newListener' when new listeners are added and 'removeListener' when existing listeners are removed.