Skip to content

Instantly share code, notes, and snippets.

@rohanBagchi
Last active February 16, 2018 05:34
Show Gist options
  • Save rohanBagchi/2fbd8d491f0bd6dd6935b2ef70f0fed8 to your computer and use it in GitHub Desktop.
Save rohanBagchi/2fbd8d491f0bd6dd6935b2ef70f0fed8 to your computer and use it in GitHub Desktop.
UserList Updated with web workers
import worker from './app.worker.js';
import WebWorker from './WebWorker';
componentDidMount() {
this.worker = new WebWorker(worker);
this.worker.addEventListener('message', event => {
const sortedList = event.data;
this.setState({
users: sortedList
})
});
}
handleSort() {
this.worker.postMessage(this.state.users);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment