本文整理汇总了TypeScript中events.EventEmitter.eventNames方法的典型用法代码示例。如果您正苦于以下问题:TypeScript EventEmitter.eventNames方法的具体用法?TypeScript EventEmitter.eventNames怎么用?TypeScript EventEmitter.eventNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类events.EventEmitter
的用法示例。
在下文中一共展示了EventEmitter.eventNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
emitter.once(1, listener4);
emitter.prependListener('send', listener5);
emitter.prependOnceListener('send', listener6);
emitter.listeners('send');
emitter.listenerCount('send');
emitter.rawListeners('send');
EventEmitter.defaultMaxListeners = 100;
console.log(`count(static): ${EventEmitter.listenerCount(emitter, 'send')}`);
console.log(`ncount: ${emitter.listenerCount('send')}`);
console.log(`maxListeners: ${emitter.getMaxListeners()}`);
console.log(`eventNames: ${emitter.eventNames().join(', ')}`);
console.log(`rawListeners count: ${emitter.rawListeners('send').length}`);
setTimeout(() => {
console.log('\n');
emitter.emit('send');
}, 1000);
setTimeout(() => {
console.log('\n');
emitter.emit('send');
emitter.removeListener('send', listener2);
}, 2000);
setTimeout(() => {
console.log('\n');
示例2: events
result = emitter.listeners(event);
}
{
let result: boolean;
result = emitter.emit(event);
result = emitter.emit(event, any);
result = emitter.emit(event, any, any);
result = emitter.emit(event, any, any, any);
}
{
let result: Array<string | symbol>;
result = emitter.eventNames();
}
{
class Networker extends events.EventEmitter {
constructor() {
super();
this.emit("mingling");
}
}
}
{
new events();
}