Last active
June 4, 2016 19:06
-
-
Save deebloo/94dcaaed24396ebe280734bf96b8b73f 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
// New workers is created for a link to an external js file | |
var myWorker = new Worker('web-worker.js'); | |
// function to fire when a message is sent from the worker. | |
myWorker.onmessage = function (e) { | |
console.log(e.data); // HELLO WORLD | |
} | |
// send a message to the worker | |
myWorker.postMessage('hello world'); |
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
// When the web worker receives a worker. look at the data and uppercase it, and send it back | |
self.onmessage = function (e) { | |
self.postMessage(e.data.tpUpperCase()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment