-
-
Save swayf/fad21b2bdc62984d39ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-main MyWorkerScript | |
-js myworkerscript.js | |
--next | |
-main MyWorkerTest | |
-js myworkertest.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using WorkerScript; | |
class MyWorkerScript extends WorkerScript { | |
public override function onMessage(e){ | |
trace("on message triggered"); | |
postMessage("ola"); | |
} | |
static function main(){ | |
new MyWorkerScript().export(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyWorkerTest { | |
public static function main(){ | |
var worker = new Worker("myworkerscript.js"); | |
worker.postMessage("coucou"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@:native("Worker") | |
extern class Worker { | |
public function new( script : String ) : Void; | |
public function postMessage( m : Dynamic ) : Void; | |
public function addEventListener( type : Dynamic , cb : Dynamic -> Void ) : Void; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WorkerScript { | |
public function new(){} | |
public function onMessage( e : Dynamic ) : Void { } | |
public inline function postMessage( m : Dynamic ) : Void { | |
untyped __js__("self.postMessage( m )"); | |
} | |
public static function export( script : WorkerScript ){ | |
untyped __js__("self.onmessage = script.onMessage"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment