I am creating a web application written in Dart that requires the creation of independent execution paths also written in Dart. (If we were not working in a browser, I would call them "threads".
I usually use Dart (very reliable) isolates to accomplish this task, but I am limited in that I need to be able to arbitrarily terminate any of these "threads" at any time without their cooperation.
If anyone is interested, this is due to the fact that in these "threads" an untrusted third-party code must be executed, and I need to be able to terminate them if they do not respond, as well as for other reasons.
As I understand it, this is not possible with dart: isolate. (Right?)
Anyway, I managed to compile some Dart code in Javascript using dart2js and execute it in Worker
, but I donβt know how I can properly call the postMessage function and respond to the onmessage event as if I were in JS. I messed up the insides of dart2js a bit and managed to configure it (in particular, the js_backend stuff) so that I could execute the postMessage
function from my code, but responding to the onmessage
event with the Dart handler is beyond my understanding of dart2js.
I looked into the js.dart library, but this works by creating script tags on the page, and this is clearly not possible for the worker.
I know this is a really strange use case, but does anyone know how I will use the dart2js internals to reply and reply to messages to an employee?
source share