mirror of
https://github.com/nasa/openmct.git
synced 2025-06-11 20:01:41 +00:00
[Plot] Unsubscribe on destroy
Unsubscribe when a plot view is destroyed; this avoids resource leaks which cause WTD-840.
This commit is contained in:
@ -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);
|
$scope.$watch('domainObject', subscribe);
|
||||||
|
|
||||||
|
// Unsubscribe when the plot is destroyed
|
||||||
|
$scope.$on("$destroy", releaseSubscription);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* Get the color (as a style-friendly string) to use
|
* Get the color (as a style-friendly string) to use
|
||||||
|
Reference in New Issue
Block a user