addEventListener
Last updated
Listens for events sent from the scene. Used to receive events from Interactions that have "Send event" as their action.
addEventListener(eventName: string, callback: (value: any) => void): Promise<void>eventName
string
Yes
Name of the event to listen for
callback
function
Yes
Function called when event is received
Promise<void>
In Studio, create an Interaction with action Send event and specify event name
The trigger can be any available Studio trigger (On click, Mouse enter, On load, etc.)
When triggered, your callback receives the value of a Variable with the same name as the event
If no Variable with the event name exists, the callback receives undefined.
Event name must match the name specified in Studio's "Send event" action
Multiple listeners can be added for the same event
Use removeEventListener() to stop listening
Last updated
await api.addEventListener("product_clicked", (value) => {
console.log("Product clicked, value:", value);
});