Proper way to handle removing devices
Posted: 06 Jun 2014 18:46
I am able to detect a zway structure change and more specifically when a device is removed. Each device has a generic VirtualDevice class that is similar to the one you have provided. I bind to certain properties and save those in a _propertyBindings variable. Is it sufficient enough to just unbind those properties when I delete it?
What is the proper procedure for removing a device? I want to eliminate any memory leaks that results from a removed device.
I create the device using
and I detect the structure changes using
What code should properly destroy the device? I understand that javascript classes do not inherently have a destructor class. Assuming I can obtain a reference to the newVirtualDevice object that was created above. Is the proper way just to
TIA. I am just trying to properly destroy the object without memory leaks.
What is the proper procedure for removing a device? I want to eliminate any memory leaks that results from a removed device.
I create the device using
Code: Select all
var newVirtualDevice = new VirtualDevice(virtualDevice.id, virtualDevice.type);
Code: Select all
zwayBinding = zway.bind(function (type, nodeId, instanceId, commandClassId) {
if (type === ZWAY_DEVICE_CHANGE_TYPES["DeviceAdded"]) {
console.log("Device Added " + nodeId);
}
else if (type === ZWAY_DEVICE_CHANGE_TYPES["DeviceRemoved"]) {
console.log("Device Removed " + nodeId);
}
}, ZWAY_DEVICE_CHANGE_TYPES["DeviceAdded"] | ZWAY_DEVICE_CHANGE_TYPES["DeviceRemoved"]);
Code: Select all
newVirtualDevice.unbindDataPoints(); //this routine unbinds all datapoint bindings
newVirtualDevice = null;