Home > Web Front-end > JS Tutorial > body text

Instructions for using the events.EventEmitter.listenerCount method in node.js_node.js

WBOY
Release: 2016-05-16 16:28:25
Original
1531 people have browsed it

Method description:

Returns the number of listeners registered for the specified event.

Syntax:

Copy code The code is as follows:

EventEmitter.listenerCount(emitter, event)

Receive parameters:

emitter Event Emitter
event event

Example:

Copy code The code is as follows:

if(events.EventEmitter.listenerCount(this, 'feedback') == 0) {
//....
}

Source code:

Copy code The code is as follows:

EventEmitter.listenerCount = function(emitter, type) {
var ret;
if (!emitter._events || !emitter._events[type])
ret = 0;
else if (util.isFunction(emitter._events[type]))
ret = 1;
else
ret = emitter._events[type].length;
Return ret;
};
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template