カスタム・イベントの公開(RecordContext)
RecordContextにカスタム・イベント公開を追加するTypeScriptの例を次に示します。
const payload: ICustomEventRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('CustomEvent') as ICustomEventRequest;
payload.setCustomEventName('customEventName');
const tabContext: ITabContext = await uiEventsFrameworkInstance.getTabContext('browserTabId');
const recordContext: IRecordContext = await tabContext.getActiveRecord();
recordContext.publish(payload).then((message) => {
console.log(message.getResponseData());
console.log(message.getResponseData().getData());
console.log(message.getResponseData().getCustomEventName());
}).catch((err) => {
console.log(err);
});
JavaScriptの例を次に示します:
const payload = uiEventsFrameworkInstance.requestHelper.createPublishRequest('CustomEvent');
payload.setCustomEventName('customEventName');
payload.setEventPayload({ message: 'any data' });
const tabContext = await uiEventsFrameworkInstance.getTabContext('browserTabId');
const recordContext: IRecordContext = await tabContext.getActiveRecord();
recordContext.publish(payload).then((message) => {
console.log(message.getResponseData());
console.log(message.getResponseData().getData());
console.log(message.getResponseData().getCustomEventName());
}).catch((err) => {
console.log(err);
});
ノート: MSI TabContextに追加されたCustomEventパブリッシュでは、そのコンテキストでアクションがサポートされていないため、エラーが発生します。
イベント・サブスクリプションおよび公開を使用すると、UEFでサポートされていないレコードに新しいライフ・サイクル・イベントを定義できます。 特定のレコード・コンテキストのカスタム・イベント・サブスクリプションは、その特定のレコード・コンテキストでカスタム・イベント公開またはVBからのカスタム・イベント・トリガーが発生した場合にのみ通知されます。 その他のレコード・コンテキスト・サブスクリプションは通知されません。 同様に、特定のブラウザ・タブ・コンテキストのカスタム・イベント・サブスクリプションは、その特定のタブ・コンテキストでカスタム・イベント公開またはVBからのカスタム・イベント・トリガーが発生した場合にのみ通知されます。 他のタブ・コンテキスト・サブスクリプションは通知されません。
カスタム・イベントのこの機能により、UEFを介したVB内の外部アプリケーションから外部アプリケーションへの通信も可能になります。