EventDispatcher

new EventDispatcher()

实现事件的订阅和发布模式

Methods

emit(event)

触发事件
Name Type Description
event Object 事件对象
Name Type Description
type String 事件类型
{custom} Object optional 传递的参数

fire(type)

触发事件
Name Type Description
type String 事件类型
...args Array.<Object> 传递的参数

has(type, listener)Boolean

是否存在指定类型的订阅事件
Name Type Description
type String
listener function
Returns:

off(type, listener)

取消指定类型的指定事件订阅
Name Type Description
type String
listener function

on(type, listener)

订阅事件
Name Type Description
type String
listener function

once(type, listener)

订阅事件,当订阅事件响应后自动取消订阅,只触发一次
Name Type Description
type String
listener function