diff --git a/platform/features/plot/src/PlotController.js b/platform/features/plot/src/PlotController.js index ef53efd87f..6449e0f3a1 100644 --- a/platform/features/plot/src/PlotController.js +++ b/platform/features/plot/src/PlotController.js @@ -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