Last active
February 28, 2017 09:25
-
-
Save psiphi75/80de0fb1e8af1d7be224c242b2d21149 to your computer and use it in GitHub Desktop.
Example of WebWorker worker
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
// This is our computation, we just initialise it for now. | |
var rt = new RayTracer(700, 700); | |
// we are in the worker.js thread so 'this' has the correct scope. | |
this.addEventListener('message', function(e) { | |
// Start the work | |
if (e.message === 'Start your work') { | |
var result = rt.raytrace(); | |
// When we are done post the result | |
this.postMessage(result); | |
} | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment