mirror of
https://github.com/nasa/openmct.git
synced 2024-12-23 15:02:23 +00:00
[Code Style] Use prototypes for execution bundle
WTD-1482.
This commit is contained in:
parent
b93d752c88
commit
7911909c5f
@ -38,8 +38,7 @@ define(
|
||||
* @constructor
|
||||
*/
|
||||
function WorkerService($window, workers) {
|
||||
var workerUrls = {},
|
||||
Worker = $window.Worker;
|
||||
var workerUrls = {};
|
||||
|
||||
function addWorker(worker) {
|
||||
var key = worker.key;
|
||||
@ -53,24 +52,24 @@ define(
|
||||
}
|
||||
|
||||
(workers || []).forEach(addWorker);
|
||||
|
||||
return {
|
||||
/**
|
||||
* Start running a new web worker. This will run a worker
|
||||
* that has been registered under the `workers` category
|
||||
* of extension.
|
||||
*
|
||||
* @param {string} key symbolic identifier for the worker
|
||||
* @returns {Worker} the running Worker
|
||||
* @memberof platform/execution.WorkerService#
|
||||
*/
|
||||
run: function (key) {
|
||||
var scriptUrl = workerUrls[key];
|
||||
return scriptUrl && Worker && new Worker(scriptUrl);
|
||||
}
|
||||
};
|
||||
this.workerUrls = workerUrls;
|
||||
this.Worker = $window.Worker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start running a new web worker. This will run a worker
|
||||
* that has been registered under the `workers` category
|
||||
* of extension.
|
||||
*
|
||||
* @param {string} key symbolic identifier for the worker
|
||||
* @returns {Worker} the running Worker
|
||||
*/
|
||||
WorkerService.prototype.run = function (key) {
|
||||
var scriptUrl = this.workerUrls[key],
|
||||
Worker = this.Worker;
|
||||
return scriptUrl && Worker && new Worker(scriptUrl);
|
||||
};
|
||||
|
||||
return WorkerService;
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user