-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
This code doesn't seem to be using a web worker. I tested by setting breakpoint on line of "new Worker" and it's never hit.
import('dart:html');
import('dart:isolate');
myIsolate() {
port.receive((msg, reply) {
print("isolate received message");
var s = new StringBuffer();
// simulate heavy work
for (var i = 0; i < 600000; i++) {
s.add("$i");
}
reply.send("I received: ${s.toString()}");
});
}
main() {
var sendPort = spawnFunction(myIsolate);
query('#myButton').on.click.add((Event e) {
print("just clicked");
sendPort.call("Hello from main").then((reply) {
print("done with message size ${reply.length}");
});
print("sent request to isolate");
});
}
I've attached the compiled JS output.
Should isolates use web workers when compiled to JavaScript ?
Attachment:
isolatesinweb.dart.js (201.12 KB)