文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>node.js之EventEmitter

node.js之EventEmitter

时间:2011-01-12  来源:imyuan

EventDispather里主要有几个方法:

  • addEventListener 使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知
  • dispatchEvent 将事件调度到事件流中
  • hasEventListener  检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器
  • removeEventListener 从 EventDispatcher 对象中删除侦听器。
  • willTrigger 检查是否用此 EventDispatcher 对象或其任何始祖为指定事件类型注册了事件侦听器。

而EventEmitter里边

  • addListener
  • emit
  • on:addLIstener的别名
  • once
  • removeListener
  • removeAllListeners
  • listeners

EventEmitter使用内部变量_events保存事件回调函数。

EventEmitter.prototype.listeners = function(type) {
  if (!this._events) this._events = {};
  if (!this._events[type]) this._events[type] = [];
  if (!isArray(this._events[type])) {
    this._events[type] = [this._events[type]];
  }
  return this._events[type];
};
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载