From 7911909c5fa8b85458e11a5d6eab7ff39d77cfa2 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 11 Aug 2015 15:02:52 -0700 Subject: [PATCH] [Code Style] Use prototypes for execution bundle WTD-1482. --- platform/execution/src/WorkerService.js | 35 ++++++++++++------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/platform/execution/src/WorkerService.js b/platform/execution/src/WorkerService.js index a428947a5c..68eb171b0f 100644 --- a/platform/execution/src/WorkerService.js +++ b/platform/execution/src/WorkerService.js @@ -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; } );