YY.emitter
消息总线,一般用于简单的异步通信
creation
constructor()
example
js
//监听事件
YY.emitter.on("event", function(data) {
console.log(data);
});
//派发事件
YY.emitter.emit("event", {
data: "hello"
});
method
TIP
static 表示静态方法, 即对象直接访问, 无需new
static
on(event,callback)
- 监听事件
- 参数
- {String}
监听事件
: 事件类型 - {Function}
callback
: 回调函数
- {String}
static
emit(event,options)
- 监听事件
- 参数
- {String}
监听事件
: 事件类型 - {Object}
options
: 参数
- {String}
static
off(event,callback)
- 移除监听事件
- 参数
- {String}
监听事件
: 事件类型 - {Function}
callback
: 回调函数
- {String}