SetOnEquipmentUserPropertiesChange
Subscribe to this event to be notified when one or more user properties change for a particular equipment.
Function
void SetOnEquipmentUserPropertiesChange(equipmentName: string, callback: function)
Parameters
- equipmentName (string): The name of the equipment for which user property changes be reported on the given function.
- callback (function(string, all)): A function that gets the key that has changed and its new value. Pass null to unregister the callback for that equipment.
Example
Print out the user properties that have changed.
function PrintUserPropertyChange(key, value)
{
console.log("UserProperty Name: " + key);
console.log("UserProperty Type: " + typeof(value));
console.log("UserProperty Value: " + value);
}
SYM3.SetOnEquipmentUserPropertiesChange("BasicShape1", PrintUserPropertyChange);
Example output:
UserProperty Name: Name
UserProperty Type: string
UserProperty Value: Fred
UserProperty Name: ArbitraryFlag
UserProperty Type: boolean
UserProperty Value: true
UserProperty Name: Age
UserProperty Type: number
UserProperty Value: 138
...
Remarks
If the same equipment name is given to this function more than once, an error will be thrown.
If the webclient disconnects and reconnects, all callbacks are unregistered.
If an equipment of the given name doesn’t exist in the current project at the time of the call, the function has no effect. If an equipment is created after the fact with such a name, you will have to unsubscribe (pass null as the second parameter) before resubscribing to it.
The only time that callbacks are removed from sym3.js’s internal tracking is if null is passed as the second parameter of this function. If a callback is registered to a product that will be removed from the project (e.g. a product) then null must be passed to this function with the equipment’s name, or the memory storing the callback will never be released.
At present, the only way to determine if an equipment has been removed is to compare the results of two GetEquipmentList calls.
Changes to user properties with a name of the pattern ‘UserPropertyN’, where N is a number, and the value is either 0, false, or an empty string will not be reported.