class sap.ui.core.postmessage.Bus

Visiblity: restricted
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/core/postmessage/Bus
Application Component: CA-UI5-COR

Responsible for the communication between different window objects.

Overview

This class is a singleton. The class instance can be retrieved as follows:

For supported data types for payload messages, see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm .


Constructor

new sap.ui.core.postmessage.Bus()

Methods Overview

Method Description
sap.ui.core.postmessage.Bus.extend

Creates a new subclass of class sap.ui.core.postmessage.Bus with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.EventBus.extend.

sap.ui.core.postmessage.Bus.getInstance

Returns an instance of the class.

sap.ui.core.postmessage.Bus.getMetadata

Returns a metadata object for class sap.ui.core.postmessage.Bus.

publish

Publish message into cross-window communication channel

subscribe

Attaches an event handler to the event with the given identifier on the given event channel

sap.ui.core.postmessage.Bus.extend

Creates a new subclass of class sap.ui.core.postmessage.Bus with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.EventBus.extend.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

sap.ui.core.postmessage.Bus.getInstance

Returns an instance of the class.

sap.ui.core.postmessage.Bus.getMetadata

Returns a metadata object for class sap.ui.core.postmessage.Bus.

publish

Publish message into cross-window communication channel

Param Type DefaultValue Description
mParameters object

Map with params

target Window

Window object of receiving window

origin string

Origin of the receiving window, e.g. http://example.com

channelId string

Channel identifier

eventId string

Event identifier

data any

Payload data. For supported data types see - https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm

subscribe

Attaches an event handler to the event with the given identifier on the given event channel

Param Type DefaultValue Description
sChannelId string

Channel of the event to subscribe to. If not given, the default channel is used. The channel "sap.ui" is reserved by the UI5 framework. An application can listen to events on this channel, but is not allowed to publish its own events there.

sEventId string

Identifier of the event to listen for

fnFunction function

Handler function to call when the event occurs; this function is called in the context of the oListener instance (if present) or on the event bus instance. Arguments:

- {string} sChannelId - Channel ID
- {string} sEventId - Event ID
- {object} mParameters - Event parameters
    - {Event} originalEvent - Post message original event
    - {string} channelId - Channel ID
    - {string} eventId - Event ID
    - {Window} source - Sender window
    - {string} origin - Sender origin, e.g. https://example.com
    - {*} [data] - Payload data

oListener object

Object that wants to be notified when the event occurs (this context within the handler function). If it is not specified, the handler function is called in the context of the event bus.