redux-worker Redux-Worker 是 Redux 的中间件,它可以帮助您通过将 reducer 移至 worker 进程中,构建多线程的 JavaScript 应用程序。
redux-worker Redux-Worker 是 Redux 的中间件,它可以帮助您通过将 reducer 移至 worker 进程中,构建多线程的 JavaScript 应用程序。
Redux-Worker is a middleware for Redux.
It helps you build multi-threaded JavaScript applications by moving your reducer into a Web Worker. It also provides a simple API for you to register tasks to be executed in the web worker outside of Redux.
Check out the demo:
(Right) Performing synchronous calculations on a separate worker thread, without blocking the main thread.
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).
It used to be difficult to conceptualize how to harness the power of Web Workers in an MVC application due to the constraint above. However, Redux has changed the way we think about building applications in JavaScript. Its three principles make it easy to move your app logic into a separate task.
If you are not familiar with web workers, I'd recommend starting with the following materials.
Redux-Worker helps you use web workers in your Redux applications. It does so by enhancing your Redux store with:
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暂无开放 Issues,或尚未同步最近议题。