Skip to content

Commit 29343c7

Browse files
committed
.addImportURL() for global libs
1 parent ae04ba1 commit 29343c7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/angular-workers.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ angular.module('FredrikSandell.worker-pool', [])
33
var that = {};
44
var urlToAngular;
55
var serviceToUrlMap = {};
6+
var importURLs = [];
67
/*jshint laxcomma:true */
78
/*jshint quotmark: false */
89
var workerTemplate = [""
@@ -60,6 +61,11 @@ angular.module('FredrikSandell.worker-pool', [])
6061
return that;
6162
};
6263

64+
// add explicit URLs for importScripts(). Use-case: angular or/and worker code uses global libraries.
65+
that.addImportURL = function (url) {
66+
importURLs.push(url);
67+
};
68+
6369
that.createAngularWorker = function (depFuncList) {
6470
//validate the input
6571

@@ -104,6 +110,9 @@ angular.module('FredrikSandell.worker-pool', [])
104110

105111
function createIncludeStatements(listOfServiceNames) {
106112
var includeString = '';
113+
angular.forEach(importURLs, function (url) {
114+
includeString += 'importScripts(\''+url+'\');';
115+
});
107116
angular.forEach(listOfServiceNames, function (serviceName) {
108117
if (serviceToUrlMap[serviceName]) {
109118
includeString += 'importScripts(\''+serviceToUrlMap[serviceName].url+'\');';

0 commit comments

Comments
 (0)