Subscribe Custom Event on TabContext
Here's a TypeScript example for adding custom event subscription on
TabContext
.
const subscribeCustomEvent = async () => {
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID','V1');
const payload: ICustomEventSubscriptionRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusCustomEvent') as ICustomEventSubscriptionRequest;
payload.setCustomEventName('customEventName');
const tabContext:ITabContext = await frameworkProvider.getTabContext('browserTabId');
tabContext.subscribe(payload, (message: IEventResponse) => {
const response: ICustomEventSubscriptionResponse = message as ICustomEventSubscriptionResponse;
console.log(response.getResponseData());
console.log(response.getResponseData().getData());
console.log(response.getResponseData().getCustomEventName())
});
};
Here's a JavaScript example for adding custom event subscription on
TabContext
.
const subscribeCustomEvent = async () => {
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID','V1');
const payload = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusCustomEvent');
payload.setCustomEventName('customEventName');
const tabContext = await frameworkProvider.getTabContext('browserTabId');
tabContext.subscribe(payload, (response) => {
console.log(response.getResponseData());
console.log(response.getResponseData().getData());
console.log(response.getResponseData().getCustomEventName())
});
};