ISubscriptionContext

The ISubscriptionContext object contains the reference to the object on which we've added a subscription on while calling a subscribe or subscribeonce API to listen to application level or object level events. You can call the dispose API on top of this object to dispose or unregister that particular subscription at any point of time.

Functions

dispose

Use this API to dispose or unregister any subscriptions that have been added for an event. By disposing the subscription, the API will not trigger any further notifications to the client side receiver.
dispose:() => void;
The following code snippet shows an example in Typescript:
/// <reference path="uiEventsFramework.d.ts"/>
      const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
      const globalContext: IGlobalContext = await frameworkProvider.getGlobalContext();
      const requestObject: IEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusTabCloseEvent');
      const subscriptionContext: ISubscriptionContext  = globalContext.subscribe(requestObject, (response: IEventResponse) => {
           // custom code
      });
      subscriptionContext.dispose();

The following code snippet shows an example in JavaScript:

const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
      const globalContext = await frameworkProvider.getGlobalContext();
      const requestObject = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusTabCloseEvent');
      const subscriptionContext = globalContext.subscribe(requestObject, (response) => {
          // custom code
      });
      subscriptionContext.dispose();