src/players/WebWorkerPlayer.js
/** The static `createWorker(playerBuilder)` method creates (asynchronously) and initializes a
	web worker. The modules `creatartis-base` and `ludorum` are loaded in the webworker's root
	namespace (`self`). If a `workerSetup` function is given, it is also run. After that, the
	`playerBuilder` function is called and its results stored in the variable `self.PLAYER`.
	*/
The static `createWorker(playerBuilder)` method creates (asynchronously) and initializes a
web worker.
The static ` createWorker ( playerBuilder ) ` method creates ( asynchronously ) and initializes a web worker .
function createWorker(params) {
		raiseIf('string function'.indexOf(typeof params.playerBuilder) < 0,
			"Invalid player builder: "+ params.playerBuilder +"!");
		raiseIf(params.workerSetup && 'string function'.indexOf(typeof params.workerSetup) < 0,
			"Invalid worker setup: "+ params.workerSetup +"!");
		var parallel = new base.Parallel(),
			deps = [exports].concat(params.dependencies || []);
		return Future.sequence(deps, function (dependency) {
				return parallel.loadModule(dependency, true);
			}).then(function () {
				return parallel.run(
					(params.workerSetup ? '('+ params.workerSetup +')(),\n' : '')+
					'self.PLAYER = ('+ params.playerBuilder +').call(self),\n'+
					'"OK"');
			}).then(function () {
				var worker = parallel.worker;
				worker.__parallel__ = parallel;
				return worker;
			});
	}
function createWorker ( params ) { raiseIf ( 'string function' . indexOf ( typeof params . playerBuilder ) < 0 , "Invalid player builder: " + params . playerBuilder + "!" ) ; raiseIf ( params . workerSetup && 'string function' . indexOf ( typeof params . workerSetup ) < 0 , "Invalid worker setup: " + params . workerSetup + "!" ) ; var parallel = new base . Parallel ( ) , deps = [ exports ] . concat ( params . dependencies || [ ] ) ; return Future . sequence ( deps , function ( dependency ) { return parallel . loadModule ( dependency , true ) ; } ) . then ( function ( ) { return parallel . run ( ( params . workerSetup ? '(' + params . workerSetup + ')(),\n' : '' ) + 'self.PLAYER = (' + params . playerBuilder + ').call(self),\n' + '"OK"' ) ; } ) . then ( function ( ) { var worker = parallel . worker ; worker . __parallel__ = parallel ; return worker ; } ) ; }
The static `createWorker(playerBuilder)` method creates (asynchronously) and initializes a
web worker.
The static ` createWorker ( playerBuilder ) ` method creates ( asynchronously ) and initializes a web worker .