subscribe(eventType, subscriptionItem, subscriptionItemName, subscribeOnce, contextName)
Notifies a subscription item whenever an event occurs in a specific context.
Returns
Not applicable.
Parameters
Name | Type | Description | Required |
eventType | string | The type of event. | ✅ |
subscriptionItem | function | The item that needs to be notified. | ✅ |
subscriptionItemName | string | A unique ID or name assigned by the user to identify the subscription item. | ✅ |
subscribeOnce | boolean | The flag that determines if the subscription item should be notified only once. | ❌ |
contextName | string | The name of the context containing the event whose subscription item must be notified. | ❌ |
Usage example
In this example, the API notifies the subscriptionItem
item whenever
an event of type eventType
occurs.
PCore.getPubSubUtils().subscribe(eventType, subscriptionItem, subscriptionItemName);
Previous topic publish(eventType, payload) Next topic subscribeOnce(eventType, subscriptionItem, subscriptionItemName)