Skip to content

voltmx.listener Namespace

The Volt MX Listener API contains the voltmx.listener Namespace and the following API elements:

Functions

The voltmx.listener namespace provides the following functions:

voltmx.listener.broadcast


The broadcast method is used to send (broadcast) data to the specified events.

Syntax

voltmx.listener.broadcast(<event_name>,payload);

Input Parameters

ParameterDescription
<event_name>The name of the event to which the data must be broadcast
payloadThe data that must be broadcast.

Example

voltmx.listener.broadcast('broadcast_event',payload);

Return Value

None

Remarks

When you broadcast data to an event, the callback functions of all the subscriptions of the event are invoked with the specified scopes, and the data is passed in the payload parameter.

Platform Availability

Adaptive Web (Mobile Web/SPA)

voltmx.listener.create


The create method is used to create an event.

Syntax

voltmx.listener.create(<event_name>);

Input Parameters

ParameterDescription
<event_name>The name of the event to be created.

Example

voltmx.listener.create('new_event');

Return Value

None

Platform Availability

Adaptive Web (Mobile Web/SPA)

voltmx.listener.destroy


The destroy method is used to destroy the specified event. When you invoke the destroy method, all the subscriptions (if there are any) of the event are also automatically unsubscribed.

Syntax

voltmx.listener.destroy(<event_name>);

Input Parameters

ParameterDescription
<event_name>The name of the event to be destroyed.

Example

voltmx.listener.destroy('event1');

Return Value

None

Platform Availability

Adaptive Web (Mobile Web/SPA)

voltmx.listener.subscribe


The subscribe method is used to subscribe to the specified event.

Syntax

voltmx.listener.subscribe(<event_name>,function(payload){}, scope);

Input Parameters

ParameterDescription
<event_name>The name of the event to which a subscription must be obtained.
functionA callback function that that is executed when the event is broadcast. The function consists of a payload parameter that contains the data that is broadcast.
scopeThe scope that needs to be used to invoke the callback function.

Example

var id = voltmx.listener.subscribe('subscribe_event',function(payload){}, scope);

Return Value

SubscriptionID - A unique string that identifies a successful subscription.

Platform Availability

Adaptive Web (Mobile Web/SPA)

voltmx.listener.unsubscribe


The unsubscribe method is used to stop receiving updates (unsubscribe) from the specified subscriptions.

Syntax

voltmx.listener.unsubscribe(subscriptionID);

Input Parameters

ParameterDescription
subscriptionIDThe Subscription ID of the event that is generated and returned by the voltmx.listener.subscribe API.

Example

voltmx.listener.unsubscribe(subscriptionID);

Return Value

None

Platform Availability

Adaptive Web (Mobile Web/SPA)