发布订阅模式的特点:
api提供了addEventListener/on/subscribe
api提供了dispatchEvent/emit/trigger
api提供了removeEventListener/off/unsubscribe
满足上述条件的对象被称为EventEmitter,实现了发布订阅模式
没有事件名触发默认事件
API:
on:添加一个事件监听器
emit:触发事件
off:把事件删除
缺点:当事件过多会难以管理
发布订阅模式的特点:
api提供了addEventListener/on/subscribe
api提供了dispatchEvent/emit/trigger
api提供了removeEventListener/off/unsubscribe
满足上述条件的对象被称为EventEmitter,实现了发布订阅模式
没有事件名触发默认事件
API:
on:添加一个事件监听器
emit:触发事件
off:把事件删除
缺点:当事件过多会难以管理