EventEmitter 类
EventEmitter
类由 events
模块定义和暴露:
const EventEmitter = require('events');
所有的 EventEmitter
,当添加新的监听器时触发事件 'newListener'
,当删除现有的监听器时触发事件 'removeListener'
。
它支持以下的选项:
captureRejections
<boolean> 启用自动捕获 promise 拒绝。
The EventEmitter
class is defined and exposed by the events
module:
const EventEmitter = require('events');
All EventEmitter
s emit the event 'newListener'
when new listeners are
added and 'removeListener'
when existing listeners are removed.
It supports the following option:
captureRejections
<boolean> It enables automatic capturing of promise rejection. Default:false
.