[Plot] Unsubscribe on destroy

Unsubscribe when a plot view is destroyed; this avoids resource
leaks which cause WTD-840.
This commit is contained in:
Victor Woeltjen 2015-02-05 17:37:47 -08:00
parent 63345bbd3b
commit f78226bc69

View File

@ -113,8 +113,20 @@ define(
}
}
// Release the current subscription (called when scope is destroyed)
function releaseSubscription() {
if (subscription) {
subscription.unsubscribe();
subscription = undefined;
}
}
// Subscribe to telemetry when a domain object becomes available
$scope.$watch('domainObject', subscribe);
// Unsubscribe when the plot is destroyed
$scope.$on("$destroy", releaseSubscription);
return {
/**
* Get the color (as a style-friendly string) to use