Last active
March 24, 2018 12:24
-
-
Save chrispsn/f90a7f347df74760d43b5d5a8d581972 to your computer and use it in GitHub Desktop.
Playing with Web Workers so we can get rid of sheet references in Mesh while not polluting the window scope.
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
var myWorker = new Worker('worker.js'); | |
myWorker.onmessage = (e) => console.log(e.data); | |
myWorker.postMessage("Hello!"); |
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
importScripts("libR.min.js"); | |
let numbers = [1, 2, 3]; | |
self.cool = () => hey | |
+ " I am a function referencing a variable before it was defined!" | |
+ "\nLook, I can import and call some R functions from a library! Sum of " + numbers + " is " + libR.R.sum(numbers); | |
self.hey = " This is a worker!"; | |
onmessage = function(e) { | |
postMessage(e.data + cool()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment