All the functions and properties available on the stub SDK
init()
Initialise stub. You'll get an error if you try call anything else before you've called this. Only the first 3 props are required, the others are optional.
renderImmediately is false by default, because most of the time you will want to initialise stub before you have rendered the DOM elements to which it should attach. But if you are running a simpler setup
render()
Render the widgets in the DOM. You can call this multiple times and stub will recreate the DOM each time—but it will not refresh the underlying data. Use refresh() if you just want to refresh the data.
window.stub.render()
refresh()
Refresh the data presented in the widgets. Use this if you've called another stub API somewhere and the widgets need to be updated to reflect the latest data.
The listener that you add will be called with exactly one parameter with details about the respective event:
{
event: '<event-name>',
srcElement: '<src-element>', // only if available
srcWidget: '<src-widget>, // only if the event was emitted by a specific widget
timeStamp: 1721121465704
}
You can see an example of this with the following:
srcElement and srcWidget may be undefined if the event originated from the SDK directly. For example, the loaded event is originated by the SDK directly—and not from a user interaction.
removeEventListener()
Remove an event listener that you've previously added. If you must.