Created
April 15, 2015 14:05
-
-
Save reyramos/daa227d87597ec9ba27d to your computer and use it in GitHub Desktop.
Webworker for angular Controller example
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.addEventListener('message', function (e) { | |
var data = e.data; | |
if (typeof (data) === "undefined") return; | |
switch (data.cmd) { | |
case 'start': | |
self.postMessage('WORKER STARTED: ' + data.msg); | |
break; | |
case 'stop': | |
self.postMessage('WORKER STOPPED: ' + data.msg + | |
'. (buttons will no longer work)'); | |
self.close(); // Terminates the worker. | |
break; | |
default: | |
self.postMessage('Unknown command: ' + data.msg); | |
}; | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment