You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 17, 2021. It is now read-only.
Alias of EventEmitter.addEventListener. Works exactly the same but will always pass true for the last argument which causes the event to only run once.
After it has been emitted it removes its self automatically.
Arguments
EventEmitter.once(type, listener, scope);
Stringtype Event type name
Functionlistener Function to be called when the event is fired
Objectscope Object that this should be set to when the listener is called
Returns
Object The current EventEmitter instance to allow chaining
Notes
You can get the same effect with EventEmitter.addListener by passing true as the fourth argument, but I would advise against it. The node API does not allow this fourth argument therefor it is mainly for internal use. Use this method to make your code more portable.
Examples
var ee = new EventEmitter();
ee.once('foo', function() {
console.log('bar');
});