Skip to content

Commit

Permalink
Improved support from plot
Browse files Browse the repository at this point in the history
  • Loading branch information
akhenry committed Jul 26, 2016
1 parent 5b2eb72 commit aa4a5e5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
3 changes: 2 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ define([
'./platform/entanglement/bundle',
'./platform/search/bundle',
'./platform/status/bundle',
'./platform/commonUI/regions/bundle'
'./platform/commonUI/regions/bundle',
'./example/msl/bundle'
], function (Main, legacyRegistry) {
return {
legacyRegistry: legacyRegistry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,26 @@ define(
function ConductorTelemetryDecorator(conductor, telemetryService) {
this.conductor = conductor;
this.telemetryService = telemetryService;

this.amendRequests = ConductorTelemetryDecorator.prototype.amendRequests.bind(this);
}

function amendRequest(request, bounds, timeSystem) {
request = request || {};
request.start = bounds.start;
request.end = bounds.end;
request.domain = timeSystem.metadata.key;

return request;
}

ConductorTelemetryDecorator.prototype.amendRequests = function (requests) {
var bounds = this.conductor.bounds(),
timeSystem = this.conductor.timeSystem();

function amendRequest(request) {
request = request || {};
request.start = bounds.start;
request.end = bounds.end;
request.domain = timeSystem.metadata.key;
return request;
}

return (requests || []).map(amendRequest);
return (requests || []).map(function (request) {
return amendRequest(request, bounds, timeSystem);
});
};

ConductorTelemetryDecorator.prototype.requestTelemetry = function (requests) {
Expand All @@ -62,8 +67,19 @@ define(
};

ConductorTelemetryDecorator.prototype.subscribe = function (callback, requests) {
return this.telemetryService
.subscribe(callback, requests);
var unsubscribeFunc = this.telemetryService.subscribe(callback, this.amendRequests(requests)),
conductor = this.conductor,
self = this;

function amendRequests() {
return self.amendRequests(requests);
}

conductor.on('bounds', amendRequests);
return function() {
unsubscribeFunc();
conductor.off('bounds', amendRequests);
}
};

return ConductorTelemetryDecorator;
Expand Down

0 comments on commit aa4a5e5

Please sign in to comment.