emitter.prependOnceListener(eventName, listener)
eventName
<string> | <symbol> 事件的名称。listener
<Function> 回调函数- 返回: <EventEmitter>
将名为 eventName
的事件的单次 listener
函数添加到监听器数组的开头。
下次触发 eventName
时,将移除此监听器,然后再调用。
server.prependOnceListener('connection', (stream) => {
console.log('Ah, we have our first user!');
});
返回对 EventEmitter
的引用,以便可以链式调用。
eventName
<string> | <symbol> The name of the event.listener
<Function> The callback function- Returns: <EventEmitter>
Adds a one-time listener
function for the event named eventName
to the
beginning of the listeners array. The next time eventName
is triggered, this
listener is removed, and then invoked.
server.prependOnceListener('connection', (stream) => {
console.log('Ah, we have our first user!');
});
Returns a reference to the EventEmitter
, so that calls can be chained.