@fastweb/event_common

1.1.0 • Public • Published

自定义事件绑定 Build Status npm


所谓自定义事件,就是有别于有别于带有浏览器特定行为的事件(类似click, mouseover, submit, keydown等事件),事件名称可以随意定义,可以通过特定的方法进行添加,触发以及删除

安装

ems:

cnpm i @fastweb/event -S

commonJs:

cnpm i @fastweb/event_common -S

例子

import Event from '@fastweb/event';
class MyClass extends Event{
  ...
  init(){
    //触发事件
    this.emit("init",params)
  }
}
//绑定事件
MyClass.on('init',function(){
  ...
})
//绑定一次事件
MyClass.one('init',function(){
  ...
})
//删除事件
MyClass.off('init',function(){
  ...
})

Readme

Keywords

none

Package Sidebar

Install

npm i @fastweb/event_common

Weekly Downloads

1

Version

1.1.0

License

ISC

Last publish

Collaborators

  • yuer
  • tellmepz
  • lkfu
  • hughgr
  • yuhonyon
  • deandai