项目中可能时不时的 需要用到 跨组件 /类的事件传递,实现一个 全局的事件管理类 会让项目 开发 方便很多
根据creator的 风格 可能会实现 以下几个 接口
//注册事件 on(name,func,obj) //注册事件列表 onAll(names,obj) //关闭事件 off(name,obj) //关闭所有事件 offAll(obj) //发射事件 emit(name,args)
用法类似于:
eventMgr.on("joinRoom",this,joinRoom,this) eventMgr.onAll(["joinRoom","exitRoom"],this) eventMgr.off("joinRoom",this) eventMgr.offAll(this) eventMgr.emit(name,message)
长按下面二维码 关注并发送 eventMgr 免费获取 源码
