EventEmitter 类


EventEmitter 类由 events 模块定义和公开:

const EventEmitter = require('events');

当添加新的监听器时,所有 EventEmitter 都会触发 '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.

It supports the following option: