Non-WCC Components Subscribing to Events
Non-WCC components can subscribe to events on the PageBus by using the PageBus.subscribe method. When a topic to which the non-WCC component has subscribed is published to the PageBus, the callback function specified in the subscribe method is invoked.
The PageBus.subscribe method passes the following parameters:
Name | Type | Description |
---|---|---|
topic | string | Topic name to which to create the subscription. This may be a wildcard topic. |
scope | object | If the value is non-null, the object specified
here becomes the context of the callback function. In other words, when the
JavaScript
this keyword is used in the callback function,
it will point to this object.
If the value is null, then the object window is used as the default context of the callback function. |
onData | function | Callback function for PageBus to invoke when a message is published on the subscribed topic. |
subscriberData | any | User-defined. Null values are permitted. This is useful when the subscriber needs to access or update any data members when the callback function is invoked. |
For WCC components, the topic has the form:
com.tibco.wcc.appModelName.prototypeModelName.componentModelName.eventName
where:
- com.tibco.wcc.appModelName - The application model name (see: app.getModelName() )
- prototypeModelName - The model name given to the prototype that contains the component, wccPrototype, by default.
- componentModelName - The model name given to the component, wccWorkItems, for example.
When the event to which you’ve subscribed is published to the PageBus, the following message is returned:
{ jss : "org.pagebus.msg.Message", jssv : "2.0.0", head : {topic : eventName}, body : bodyObject }
where:
- bodyObject is a
JavaScript object that contains the data expected by the WCC component that
subscribes to that event.
For information about the data in this object for each event, see Component PageBus Event Payloads.
For more details about using the subscribe method, see the TIBCO PageBus™ Developer’s Guide.