emitter.prependOnceListener(eventName, listener)
-
listener
<Function> 回调函数¥
listener
<Function> The callback function -
¥Returns: <EventEmitter>
将名为 eventName
的事件的一次性 listener
函数添加到监听器数组的开头。下次触发 eventName
时,将移除此监听器,然后再调用。
¥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!');
});
返回对 EventEmitter
的引用,以便可以链式调用。
¥Returns a reference to the EventEmitter
, so that calls can be chained.