40
rated 0 times
[
47]
[
7]
/ answers: 1 / hits: 7535
/ 11 Years ago, thu, january 2, 2014, 12:00:00
From the nodejs source code (LOC 179), we have the following:
EventEmitter.prototype.once = function(type, listener) {
/** ... **/
function g() { /** ... **/ }
g.listener = listener; // => ???
this.on(type, g);
return this;
};
So far, my thinking goes like this:
EventEmitter.once()
sets an event of type
and removes it immediately once the callback listener
has been called via the g()
. But what really does the line g.listener = listener;
do?
Does it add a property listener
which is a function to the function object created by the constructor g()
at the time of invocation?
More From » node.js