class sap.ui.core.support.usage.EventBroadcaster

Visiblity: restricted
UX Guidelines:
Implements:
Available since: N/A
Extends:
Module: sap/ui/core/support/usage/EventBroadcaster
Application Component: CA-UI5-COR

Broadcasts UI5 events via single native custom browser event. This way consumers have a generic mechanism for hooking into any UI5 event. Example consumer code:

    window.addEventListener("UI5Event", function(oEvent) {

    		// consumer coding, e.g. :
    		// analyze event
    		// store events - GDPR is responsibility of the consumer
    		// or any other

    		var oDetail = oEvent.detail;

    		console.log("UI5 Event " 				+ oDetail.eventName
    			+ " occurred at " 					+ new Date(oDetail.timestamp).toString()
    			+ " for element " 					+ oDetail.targetId
    			+ " of type "						+ oDetail.targetType
    			+ ", which is part of component " 	+ oDetail.componentId
    			+ " with version " 					+ oDetail.componentVersion
    			+ " and additional parameters "		, oDetail.additionalAttributes);

    });


Documentation links:


Constructor

Event broadcaster. This class is meant for private usages. Apps are not supposed to used it. It is created for an experimental purpose.

new sap.ui.core.support.usage.EventBroadcaster()

Methods Overview

Method Description
sap.ui.core.support.usage.EventBroadcaster.broadcastEvent

Broadcasts an UI5 event. This method should not be called directly, but rather upon event firing.

sap.ui.core.support.usage.EventBroadcaster.broadcastRouteMatched

Broadcast an UI5 Routing event. This method should not be called directly, but rather upon event firing.

sap.ui.core.support.usage.EventBroadcaster.disable

Disables the EventBroadcaster.

sap.ui.core.support.usage.EventBroadcaster.enable

Starts broadcasting events. Consumers could stop broadcasting via EventBroadcaster.disable

sap.ui.core.support.usage.EventBroadcaster.getEventsExcludeList

Returns the currently set ExcludeList configuration. Returned object is copied from the original one. In case you modify it, you have to set it by using the setEventExcludeList setter in order for it to take effect.

sap.ui.core.support.usage.EventBroadcaster.setEventsExcludeList

Sets a new ExcludeList configuration.

ExcludeList configuration should have the following structure as in the example shown below.

In global object, we set all events that we don't want to track. In controls object, we can list different controls and include or exclude events for them.

For example, in this configuration the load event is exposed for the sap.m.Image control regardless of it being excluded globally for all other controls.

For sap.m.Button control, we don't want to track the tap event but we need to track the afterRendering event.

In the case where we write in the controls object a control without any excluded or included events, this control is NOT tracked at all.

In the example configuration events coming from control sap.m.AccButton are not be exposed.

{
		global: ["modelContextChange", "beforeRendering", "afterRendering",
				"propertyChanged", "beforeGeometryChanged", "geometryChanged",
				"aggregationChanged", "componentCreated", "afterInit",
				"updateStarted", "updateFinished", "load", "scroll"
				],
		controls: {
			"sap.m.Image": {
				include: ["load"]
			},
			"sap.m.Button": {
				exclude: ["tap"],
				include: ["afterRendering"]
			},
			"sap.m.AccButton": {}
		}
	}
The set configuration object is copied from the given one.

sap.ui.core.support.usage.EventBroadcaster.broadcastEvent

Broadcasts an UI5 event. This method should not be called directly, but rather upon event firing.

Param Type DefaultValue Description
sEventId string

the name of the event

oElement sap.ui.core.Element

The event's target UI5 element

mParameters object

The parameters which complement the event

sap.ui.core.support.usage.EventBroadcaster.broadcastRouteMatched

Broadcast an UI5 Routing event. This method should not be called directly, but rather upon event firing.

Param Type DefaultValue Description
sEventId string

the name of the event

sElementId string

the container control tis navigation is fired on

oRouter sap.ui.core.routing.Router

The underlying router

sap.ui.core.support.usage.EventBroadcaster.disable

Disables the EventBroadcaster.

sap.ui.core.support.usage.EventBroadcaster.enable

Starts broadcasting events. Consumers could stop broadcasting via EventBroadcaster.disable

sap.ui.core.support.usage.EventBroadcaster.getEventsExcludeList

Returns the currently set ExcludeList configuration. Returned object is copied from the original one. In case you modify it, you have to set it by using the setEventExcludeList setter in order for it to take effect.

sap.ui.core.support.usage.EventBroadcaster.setEventsExcludeList

Sets a new ExcludeList configuration.

ExcludeList configuration should have the following structure as in the example shown below.

In global object, we set all events that we don't want to track. In controls object, we can list different controls and include or exclude events for them.

For example, in this configuration the load event is exposed for the sap.m.Image control regardless of it being excluded globally for all other controls.

For sap.m.Button control, we don't want to track the tap event but we need to track the afterRendering event.

In the case where we write in the controls object a control without any excluded or included events, this control is NOT tracked at all.

In the example configuration events coming from control sap.m.AccButton are not be exposed.

{
		global: ["modelContextChange", "beforeRendering", "afterRendering",
				"propertyChanged", "beforeGeometryChanged", "geometryChanged",
				"aggregationChanged", "componentCreated", "afterInit",
				"updateStarted", "updateFinished", "load", "scroll"
				],
		controls: {
			"sap.m.Image": {
				include: ["load"]
			},
			"sap.m.Button": {
				exclude: ["tap"],
				include: ["afterRendering"]
			},
			"sap.m.AccButton": {}
		}
	}
The set configuration object is copied from the given one.