Caplin Trader 5.1.0

Class: module:ct-component/comms/OpenAjaxChannelSubscriptionHelper

module:ct-component/comms/OpenAjaxChannelSubscriptionHelper(oComponent, sNameSpace, sEventName, oCallbackScope, fCallbackMethod)

new module:ct-component/comms/OpenAjaxChannelSubscriptionHelper(oComponent, sNameSpace, sEventName, oCallbackScope, fCallbackMethod)

The module:ct-component/comms/OpenAjaxChannelSubscriptionHelper can be used to help manage OpenAjax subscriptions. Subscriptions are formed of a namespace, a channel, and an event in the format "namespace.channel.event". The "channel" is generally linked to a module:ct-component/Component or group of components.

However, the channel associated with a component can change during runtime so managing the subscriptions to OpenAjax events can result in duplicate code being written to handle the channel being changed, unsubscribing from the previous channel, and subscribing to the new channel. The module:ct-component/comms/OpenAjaxChannelSubscriptionHelper can be used to manage this for you and all you need to do is supply the component, the namespace, the event name and a callback scope (object) and callback method.

Parameters:
Name Type Description
oComponent module:ct-component/Component

The component that the channel subscription should be made for.

sNameSpace String

The namespace of the event being subscribed to. Events have the following format "namespace.channel.event".

sEventName String

The name of the event being subscribed to.

oCallbackScope Object

The object that the callback will be made on. The method that will be called is identified by the fCallbackMethod parameter.

fCallbackMethod function

The method to be called on the oCallbackScope object.

Implements:
Deprecated:
  • This is deprecated now. You should use the EventHub instead of the open ajax comms.

Methods

finalize()

Called to clear down the object.

getChannelId()

Gets the current channel ID.

onChannelRemoved(oComponent, sChannelId)

Called when the channel associated with the given component is removed.

Parameters:
Name Type Description
oComponent module:ct-component/Component

The component that the channel subscription to be set for.

sChannelId String

The Id of the channel

Implements:

onChannelSet(oComponent, sChannelId)

Called when the channel for the given component is set.

Parameters:
Name Type Description
oComponent module:ct-component/Component

The component that the channel subscription to be set for.

sChannelId String

The Id of the channel

Implements: