Communicating among widgets
Get the Widget Instance
WidgetId is returned while opening the modal window. It can be used to the widget instance.
Snippet
const widgetApp = sdk.getWidget(widgetID);
Emit the details to Modal window
Using widget instance to send the data to the modal window.
Snippet
widgetApp.emit("model.view", data);
- data: the data sent to model window.
Listening to events in modal window
To receive the data sent by the parent window, the modal window needs to subscribe the event.
Snippet
sdk.on("model.view", (data) => function);
- function: to process the data sent from the parent window.
Event Binding
ON: To subscribe/listen specific event.
Snippet
sdk.on(event_name, handler);
- event_name: Name for the event to subscribe.
- handler: Function which will be triggered when the event is triggered.
OFF: To unsubscribe to previously subscribed event.
Snippet
sdk.off(event_name, handler);
- event_name: Name for the event.
- handler: Reference to the function which handled that event.
Trigger
The method used to trigger the event.
Snippet
sdk.trigger(event_name, data);
- event_name: Name for the event.
- data: Data associated with the event.