WorkerSocket
createWorkerScript(script, { List<String> args, Map<String, dynamic> metadata })
Source
WorkerSocket createWorkerScript(script,
{List<String> args, Map<String, dynamic> metadata}) {
var receiver = new ReceivePort();
var socket = new WorkerSocket.master(receiver);
Uri uri;
if (script is Uri) {
uri = script;
} else if (script is String) {
uri = Uri.parse(script);
} else {
throw new ArgumentError.value(
script, "script", "should be either a Uri or a String.");
}
Isolate.spawnUri(uri, [], {"port": receiver.sendPort, "metadata": metadata})
.then((x) {
socket._isolate = x;
});
return socket;
}