From 5940f946441df9b22299b2239206406c96552645 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 3 Nov 2015 15:24:38 -0800 Subject: [PATCH] [Time Conductor] Cancel requests Don't callback for any telemetry requests from a TelemetryHandle if the handle has been destroyed. --- platform/telemetry/src/TelemetryHandle.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/telemetry/src/TelemetryHandle.js b/platform/telemetry/src/TelemetryHandle.js index ff77d7b9e0..11fd05bb90 100644 --- a/platform/telemetry/src/TelemetryHandle.js +++ b/platform/telemetry/src/TelemetryHandle.js @@ -39,6 +39,7 @@ define( */ function TelemetryHandle($q, subscription) { var seriesMap = {}, + active = true, self = Object.create(subscription); // Request a telemetry series for this specific object @@ -50,7 +51,7 @@ define( // Store it for subsequent lookup seriesMap[id] = series; // Notify callback of new series data, if there is one - if (callback) { + if (callback && active) { callback(telemetryObject, series); } // Pass it along for promise-chaining @@ -61,6 +62,10 @@ define( return telemetry.requestData(request).then(receiveSeries); } + self.unsubscribe = function () { + active = false; + return subscription.unsubscribe(); + }; /** * Get the most recently obtained telemetry data series associated