Created
October 2, 2020 10:11
-
-
Save sverhoeven/42230347c3b0c511b501184faa28d6ae to your computer and use it in GitHub Desktop.
run-cpp-on-web: kitchen-sink
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
const [result, setResult] = React.useState({ root: undefined, iterations: [] }); | |
function handleSubmit(event) { | |
event.preventDefault(); | |
const worker = new Worker('worker.js'); | |
worker.onmessage = function (message) { | |
if (message.data.type === 'RESULT') { | |
const result = message.data.payload; | |
setResult(result); | |
worker.terminate(); | |
} | |
}; | |
worker.postMessage({ | |
type: 'CALCULATE', | |
payload: { tolerance: tolerance, initial_guess: initial_guess } | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment