See the API docs.
The Web Workers API has been around for several years now, but we have yet to see much adoption from the community. I think this is mostly due to setup complexity, asynchronous message passing, and the need to think in a different context (one can't share functions/references between Worker threads).
If you are not familiar with web workers, I'd recommend starting with the following materials.
- How fast are web workers? - by Guillaume Cedric Marty
- Using Web Workers for more responsive apps - by Jason Teplitz
Redux-Web-Worker helps you use web workers in your Redux applications. It does so by enhancing
your Redux store with:
- A dispatcher that posts messages to a worker thread
- A replacement reducer that listens to messages from a Web Worker and then updates state
- A mechanism to register and execute tasks in a Web Worker using the dispatcher, which returns a promise that will resolve when the task completes.
It spawns just one Web Worker instance, so don't give it more credit than it deserves. It does not provide an interface for spawning multiple workers and balancing work between them: this is a much more complicated problem that Redux-Worker is not attempting to solve.
To run a demo locally, cd into a folder in the demo directory, and then:
npm i npm run watch