Last active
February 4, 2020 14:52
-
-
Save leon0707/13001e2c9923fad7b5e8c948579970d8 to your computer and use it in GitHub Desktop.
Revisions
-
leon0707 revised this gist
Feb 4, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // shared-worker.js onconnect = function(e) { var port = e.ports[0]; port.onmessage = function(e) { port.postMessage('send msg back to a script'); } } -
leon0707 created this gist
Feb 4, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ // shared-worker.js onconnect = function(e) { var port = e.ports[0]; port.onmessage = function(e) { port.postMessage('send msg back to a script'); } } // client if (!!window.SharedWorker) { const myWorker = new SharedWorker("shared-worker.js"); myWorker.port.postMessage('msg to a shared worker'); myWorker.port.onmessage = function(e) { console.log(e.lastEventId); } }