Last active
February 16, 2018 05:34
-
-
Save rohanBagchi/2fbd8d491f0bd6dd6935b2ef70f0fed8 to your computer and use it in GitHub Desktop.
UserList Updated with web workers
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 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