[Code Style] Use prototypes for execution bundle

WTD-1482.
This commit is contained in:
Victor Woeltjen 2015-08-11 15:02:52 -07:00
parent b93d752c88
commit 7911909c5f

View File

@ -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;
}
);