UI5 EventBus

简介: UI5 EventBus

Question

ui5的getEventBus底层是怎么实现的?效率怎么样?


Answer

No special implementation, just normal subscriber - publisher design pattern.

Event subscriber gets EventBus instance via


sap.ui.getCore().getEventBus()

1image.png

Subscriber code uses API subscribe to register the event handler provided by application with a given event.

In my example, my event handler is function onOrderApproved, and the event I would like to listen to is “OrderApproved”.


image.png

The event registration is done based on channel id.

image.png

In EventBus singleton instance there is a central repository mEventRegistery which is actually a map: key is event id, value is an array containing all listeners for this event.

image.png


When the event publisher has event to raise,

image.png

it simply goes through the previously mentioned event registry mEventRegistery,

image.png

and:

image.png

this is how the event handler defined in application is called:

image.png

regarding the performance, as you see this implementation is quite lean and no additional runtime overhead is there, performance should be quite good.


相关文章
使用 SAP UI5 Event Bus 机制,修复 SAP UI5 分页显示数据的一个 bug 试读版
使用 SAP UI5 Event Bus 机制,修复 SAP UI5 分页显示数据的一个 bug 试读版
|
Android开发 数据库管理
android eventbus ui sqlite http
    实战 QQ demo源码(本例中有该应用) 服务器端下载:http://download.csdn.net/download/knight_black_bob/9822551 android eclipse 版:http://download.
739 0
|
6月前
|
前端开发 搜索推荐 开发者
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
|
6月前
|
JavaScript 前端开发 开发者
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
|
6月前
|
前端开发 JavaScript API
SAP UI5 sap.ui.require.toUrl 的作用介绍
SAP UI5 sap.ui.require.toUrl 的作用介绍
|
6月前
|
JSON 前端开发 测试技术
SAP UI5 sap.ui.core.util.MockServer.simulate 方法介绍
SAP UI5 sap.ui.core.util.MockServer.simulate 方法介绍
|
6月前
|
缓存 JavaScript 前端开发
如何理解 SAP UI5 的 sap.ui.define 函数?
如何理解 SAP UI5 的 sap.ui.define 函数?
|
6月前
|
监控 测试技术
SAP 电商云修改 Product Catalog Staged 版本数据后,同步到 online 版本的 UI 操作
SAP 电商云修改 Product Catalog Staged 版本数据后,同步到 online 版本的 UI 操作