File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ angular.module('FredrikSandell.worker-pool', [])
3
3
var that = { } ;
4
4
var urlToAngular ;
5
5
var serviceToUrlMap = { } ;
6
+ var importURLs = [ ] ;
6
7
/*jshint laxcomma:true */
7
8
/*jshint quotmark: false */
8
9
var workerTemplate = [ ""
@@ -60,6 +61,11 @@ angular.module('FredrikSandell.worker-pool', [])
60
61
return that ;
61
62
} ;
62
63
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
+
63
69
that . createAngularWorker = function ( depFuncList ) {
64
70
//validate the input
65
71
@@ -104,6 +110,9 @@ angular.module('FredrikSandell.worker-pool', [])
104
110
105
111
function createIncludeStatements ( listOfServiceNames ) {
106
112
var includeString = '' ;
113
+ angular . forEach ( importURLs , function ( url ) {
114
+ includeString += 'importScripts(\'' + url + '\');' ;
115
+ } ) ;
107
116
angular . forEach ( listOfServiceNames , function ( serviceName ) {
108
117
if ( serviceToUrlMap [ serviceName ] ) {
109
118
includeString += 'importScripts(\'' + serviceToUrlMap [ serviceName ] . url + '\');' ;
You can’t perform that action at this time.
0 commit comments