Sunday, 2 April 2017

Figure out callback called behaviors or event emitter identification

I have a piece of code as below, however from the log looks like it has been loged 6 times.

What I really want to figure out is: whether is because the event 'data' has happened 6 times, or because of the callback function gets bound 6 times (that means the event only happens 1 time)?

Is there any id showing the current node event loop id or something?

Many thanks.

peer.on('data', function(data) {
  console.log("peer on data:", data);
});



via Xin

No comments:

Post a Comment