vue.js - 对事件总线的性能影响
问题描述
在我们的 Vue 应用程序中,我们使用多个事件总线来接收/发送事件。
方法 A:单独的事件总线
有些组件只需要处理一个通道(我们只需要导入我们需要的总线)。
import Vue from 'vue'
export const CanvasBus = new Vue()
export const NotificationBus = new Vue()
export const FileBus = new Vue()
export const UIBus = new Vue()
方法 B:一个事件总线
我们可以只有一个事件总线来处理所有事件,但这意味着所有事件都被发送到所有侦听器。
import Vue from 'vue'
export const EventBus = new Vue()
使用这种方法,每个事件都会有一个额外的参数type
(可能是“Canvas”、“UI”、“File”等)。
问题: 是否存在某种方式的性能影响,例如必须加载多个 Vue 实例,或者不用担心,它只是归结为组织偏好?
解决方案
推荐阅读
- java - @OneToOne 单向映射中实体的映射中的重复列
- swift - 比较 Any 类型的参数
- web-crawler - 如何使用 crawler4j 添加(集成) crawljax?
- python - 逗号分隔符的推荐替代方案是什么
- android - 如何在同一 X 轴坐标上获取文本块 [Google Cloud Vision API]
- sql - Azure 基本层 DTU - 基本层 (B DTU) 的不同费率
- python - 尝试解析 JSON 文件时不理解此 TypeError
- html - 使用多个 css 类创建类名不起作用
- vega - 使用在线 Vega 编辑器自定义字体?
- hyperledger-fabric - AWS CloudFormation 启动 Hyperledger Fabric 失败并出现错误:创建失败:[EC2InstanceForDev]