stdweb icon indicating copy to clipboard operation
stdweb copied to clipboard

How to use with web workers?

Open FliegendeWurst opened this issue 6 years ago • 2 comments

I would like to execute everything in a web worker, but I couldn't find any docs about that.

FliegendeWurst avatar Jul 25 '18 19:07 FliegendeWurst

after poking around a bit I am not seeing anything related to web workers in src, but it's something you (or somebody else) could look at adding? you could maybe start by looking at src/webcore/promise.rs as an example and implement a Worker struct with methods that match the web worker spec.

rickycodes avatar Jul 26 '18 16:07 rickycodes

Well, if you want to execute everything in a web worker you could just write a little JS code in your .html file and call new Worker("your-module.js") instead of including your module with a <script>, however there are currently no bindings for the web workers APIs so you'd have to use the js! macro from the inside of your module to actually communicate with the main thread. (Which shouldn't be a big deal since you can pass almost anything through the js! macro.)

koute avatar Jul 26 '18 20:07 koute