Type Alias MessageEventHandler<P>

MessageEventHandler<P>: ((event: WidgetMessageEvent<P>, sdk: ISDK, widget: IWidget) => void | Promise<void>)

The handler for a event message. Please note that the sdk and widget passed are in their interface base form, which may not have all the methods available. Use a local variable to store the sdk and widget in their extended form if you need to access the additional methods.

Type Parameters

  • P
const sdk = new TecsafeWidgetSDK();
sdk.on(InMessagePing, (e) => { // explicitly don't use `(e, sdk, widget)` here, to use the local variable
console.log(e.event, sdk);
// if you need to respond to the message, you can still use e.respond()
e.respond(OutMessagePong.create({} as any))