Last active
November 14, 2018 22:23
-
-
Save mikehibm/aaee4cac31af88524e7741ab1f6af02a to your computer and use it in GitHub Desktop.
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
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
import createWorker from './createWorker'; | |
import myWorkerFunc from './myWorker'; | |
ReactDOM.render(<App />, document.getElementById('root')); | |
// Testing Web Worder | |
const myWorker = createWorker(myWorkerFunc); | |
myWorker.addEventListener('message', (m: any) => { | |
console.log('msg', m.data.msg); | |
if (m.data.count >= 10) { | |
console.log('clearing'); | |
myWorker.postMessage({ action: 'clear' }); | |
} | |
}); | |
setInterval(() => { | |
myWorker.postMessage({ action: 'count' }); | |
}, 400); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment