[Telemetry] Stop refreshing on destroy

Stop polling for updates to telemetry data from
TelemetryController when scope is destroyed.
Addresses some performance issues observed in
WTD-614, autoflow tabular views (although this
view doesn't use TelemetryController directly,
the continuing of this polling in the background
can slow down updates when it is showing.)
This commit is contained in:
Victor Woeltjen 2014-12-29 18:29:31 -08:00
parent 34bb2ff51a
commit becc858349

View File

@ -49,7 +49,11 @@ define(
// Used for getTelemetryObjects; a reference is
// stored so that this can be called in a watch
telemetryObjects: []
telemetryObjects: [],
// Whether or not this controller is active; once
// scope is destroyed, polling should stop.
active: true
};
// Broadcast that a telemetryUpdate has occurred.
@ -227,14 +231,25 @@ define(
}
self.refreshing = false;
startTimeout();
if (self.active) {
startTimeout();
}
}, self.interval);
}
}
// Stop polling for changes
function deactivate() {
self.active = false;
}
// Watch for a represented domain object
$scope.$watch("domainObject", getTelemetryObjects);
// Stop polling when destroyed
$scope.$on("$destroy", deactivate);
// Begin polling for data changes
startTimeout();