node.js中的events.emitter.removeAllListeners方法使用說明
方法說明:
移除所有監(jiān)聽器,如果指定event,則將移除指定事件的所有監(jiān)聽器。
語(yǔ)法:
emitter.removeAllListeners([event])
接收參數(shù):
event 事件類型,支持多個(gè)
例子:
//移除所有監(jiān)聽器
emitter.removeAllListeners()
//移除指定event的所有監(jiān)聽器
emitter.removeAllListeners('data')
源碼:
EventEmitter.prototype.removeAllListeners = function(type) {
var key, listeners;
if (!this._events)
return this;
// not listening for removeListener, no need to emit
if (!this._events.removeListener) {
if (arguments.length === 0)
this._events = {};
else if (this._events[type])
delete this._events[type];
return this;
}
// emit removeListener for all listeners on all events
if (arguments.length === 0) {
for (key in this._events) {
if (key === 'removeListener') continue;
this.removeAllListeners(key);
}
this.removeAllListeners('removeListener');
this._events = {};
return this;
}
listeners = this._events[type];
if (util.isFunction(listeners)) {
this.removeListener(type, listeners);
} else {
// LIFO order
while (listeners.length)
this.removeListener(type, listeners[listeners.length - 1]);
}
delete this._events[type];
return this;
};
- node.js中的events.emitter.once方法使用說明
- 詳解Node.js:events事件模塊
- node.js中的events.emitter.removeListener方法使用說明
- node.js中的events.EventEmitter.listenerCount方法使用說明
- 關(guān)于Node.js的events.EventEmitter用法介紹
- node.js中的events.emitter.listeners方法使用說明
- node.js學(xué)習(xí)之事件模塊Events的使用示例
- 詳解如何模擬實(shí)現(xiàn)node中的Events模塊(通俗易懂版)
- nodejs事件的監(jiān)聽與觸發(fā)的理解分析
- Node.js中的事件驅(qū)動(dòng)編程詳解
- Nodejs中自定義事件實(shí)例
- node.js中事件觸發(fā)器events的使用方法實(shí)例分析
相關(guān)文章
nodejs使用http模塊發(fā)送get與post請(qǐng)求的方法示例
這篇文章主要介紹了nodejs使用http模塊發(fā)送get與post請(qǐng)求的方法,結(jié)合實(shí)例形式分析了nodejs基于http模塊實(shí)現(xiàn)發(fā)送get與post請(qǐng)求具體操作技巧,需要的朋友可以參考下2018-01-01
node簡(jiǎn)單實(shí)現(xiàn)一個(gè)更改頭像功能的示例
本篇文章主要介紹了node簡(jiǎn)單實(shí)現(xiàn)一個(gè)更改頭像功能的示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-12-12
利用express啟動(dòng)一個(gè)server服務(wù)的方法
下面小編就為大家?guī)硪黄胑xpress啟動(dòng)一個(gè)server服務(wù)的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-09-09
利用Node.JS實(shí)現(xiàn)郵件發(fā)送功能
其實(shí)利用Node.JS實(shí)現(xiàn)郵件發(fā)送這個(gè)功能很多人都寫過了,但是網(wǎng)上有的代碼不能用,版本較老,所以想著寫下自己摸索的方法來實(shí)現(xiàn)。現(xiàn)在分享給大家,感興趣的朋友們可以一起學(xué)習(xí)學(xué)習(xí)。2016-10-10
使用nodejs實(shí)現(xiàn)JSON文件自動(dòng)轉(zhuǎn)Excel的工具(推薦)
這篇文章主要介紹了使用nodejs實(shí)現(xiàn),JSON文件自動(dòng)轉(zhuǎn)Excel的工具,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-06-06
nodejs后臺(tái)集成ueditor富文本編輯器的實(shí)例
本篇文章主要介紹了nodejs后臺(tái)集成ueditor富文本編輯器的實(shí)例,具有一定的參考價(jià)值,有興趣的可以了解一下2017-07-07
Node發(fā)出HTTP POST請(qǐng)求的方法實(shí)例小結(jié)
這篇文章主要介紹了Node發(fā)出HTTP POST請(qǐng)求的方法,結(jié)合實(shí)例形式總結(jié)分析了三種常用的post請(qǐng)求操作方法,以及相關(guān)庫(kù)操作注意事項(xiàng),需要的朋友可以參考下2023-05-05

