Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

subscribe(eventType, subscriptionItem, subscriptionItemName, subscribeOnce, contextName)

Updated on July 20, 2021

Notifies a subscription item whenever an event occurs in a specific context.

Returns

Not applicable.

Parameters

NameTypeDescriptionRequired
eventTypestringThe type of event.
subscriptionItemfunctionThe item that needs to be notified.
subscriptionItemNamestringA unique ID or name assigned by the user to identify the subscription item.
subscribeOncebooleanThe flag that determines if the subscription item should be notified only once.
Note:
  • The default value is false.
  • Set subscribeOnce to true if you want to notify the subscription item only once.
contextNamestringThe name of the context containing the event whose subscription item must be notified.
Note:
  • You must update to Pega 8.7.2 or later patches to be able to use this parameter.
  • The default value of contextName is app.

Usage example

In this example, the API notifies the subscriptionItem item whenever an event of type eventType occurs.

PCore.getPubSubUtils().subscribe(eventType, subscriptionItem, subscriptionItemName);

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us