Last active
August 29, 2015 14:02
-
-
Save wittawasw/a2fe3500515727ab24a7 to your computer and use it in GitHub Desktop.
Web Worker concept
This file contains hidden or 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
(function() { | |
var worker = new Worker("js/worker.js"); | |
worker.onmessage = function(e) { | |
alert("worker: " + e.data); | |
} | |
worker.postMessage('start'); | |
// send msg the worker. | |
})(); |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="js/application.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains hidden or 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
self.onmessage = function(e) { | |
// free to do anything here. | |
self.postMessage('Hello ' + e.data); | |
// return msg to parent. | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment