[Telemetry] Add telemetry subscriptions

Add ability to subscribe/unsubscribe to streaming
telemetry updates. This may be more performant than
polling in some circumstances, and appears necessary
for good performance of autoflow tabular views,
WTD-614.
This commit is contained in:
Victor Woeltjen
2014-12-29 13:36:53 -08:00
parent 7db5c0692b
commit 8c55a66320
3 changed files with 99 additions and 10 deletions

View File

@ -38,6 +38,23 @@ define(
})).then(mergeResults);
}
// Subscribe to updates from all providers
function subscribe(callback, requests) {
var unsubscribes = telemetryProviders.map(function (provider) {
return provider.subscribe(callback, requests);
});
// Return an unsubscribe function that invokes unsubscribe
// for all providers.
return function () {
unsubscribes.forEach(function (unsubscribe) {
if (unsubscribe) {
unsubscribe();
}
});
};
}
return {
/**
* Request telemetry data.