Created
November 2, 2019 21:48
-
-
Save Legends/2c8e3e9500df14794de8f7f9e56c2d7a to your computer and use it in GitHub Desktop.
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
| // *************************** Main.js ********************************** | |
| var worker = new Worker('/Scripts/fileupload.js'); // fileupload.js is our webworker script file | |
| worker.onmessage = (e) => { // called when ww calls self.postMessage | |
| console.log(e.data); | |
| }; | |
| worker.onerror = (e) => { // onerror | |
| console.log('ERROR: Line ', e.lineno, ' in ', e.filename, ': ', e.message); | |
| } | |
| worker.postMessage({ 'files': files }); // calls self.onmessagein the ww | |
| worker.terminate(); // called to terminate the ww | |
| // *************************** fileupload.js (WebWorker) ********************************** | |
| self.onmessage = (e) => { // ww receives message | |
| for (var j = 0; j < e.data.files.length; j++) | |
| files.push(e.data.files[j]); | |
| if (p) { | |
| process(); | |
| } | |
| }; | |
| // calls worker.onmessage | |
| // ww posts message back to page or script which created the ww | |
| self.postMessage(blob.name + " Uploaded Succesfully"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment