神刀安全网

ES2015 implementation of node EventEmitter

events2

ES2015 implementation of nodejs EventEmitter

Why?

ES2015 is awesome, so why not?

  • highly readable
  • class instead of constructor function EventEmitter
  • Map() instead of {} as events storage
  • Set() instead of array as event listeners storage
  • Array.from(arguments) instead of [].slice.call

What’s different from core EventEmitter?

  • emitter.off([eventName, listener]) method

    This is an alias for core emitter.removeListener AND emitter.removeAllListeners . Removes all listeners, or those of the specified event, or specified listener.

  • no defaultMaxListeners limit
  • as a result – no getMaxListners() / setMaxListeners()
  • no listeners() and listenersCount()

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » ES2015 implementation of node EventEmitter

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
分享按钮