SubscribeToEvent
Subscribes to an event callback exposed by a component
Note: Some events do not support multiple subscription. See more in component.
🔁 Function
void SubscribeToEvent(
event: string,
componentName: string,
componentTypeName: string,
callback: string);
or
void SubscribeToEvent(
event: string,
componentName: string,
componentTypeName: string,
callback: object);
⚙️ Parameters
Name | Type | Description |
---|---|---|
event |
String | The name of the event to subscribe to |
componentName |
String | The name of the component that will invoke the event |
componentTypeName |
String | The type of the component. e.g. ‘PE Sensor’. See options |
callback |
Object | Can be a string (The name of the callback function) or the callback function itself |
↩️ Return Value
None
📝 Example
function OnSimulationStart() {
SubscribeToEvent("OnProductBlocking", "PESensor1", "PE Sensor", OnProductBlocking_PESensor1);
}
function OnProductBlocking_PESensor1(sender, product) {
MoveProduct(product, "Conveyor2", 0.3);
}