-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stores as web workers? #263
Comments
Yeah, I think it's doable, probably via higher-order stores (more powerful than middleware). Example of HOS for Redux DevTools (soon to be published): https://github.com/gaearon/redux/blob/e019f334ebfda3a99ba8bb7377b8496e059d594a/examples/counter/redux-devtools/index.js The idea is that HOSs have |
Here's a prototype I was playing around with last week, the web worker is created in the middleware which is probably the wrong spot, since you have no way to terminate it: https://gist.github.com/tappleby/342754c4a3fe02d82ec0 Depending on your stack you might be able to use RxJs + redux-rx |
Yeah as soon as you want some control, HOS is a better fit than middleware. const composedCreateStore = compose(
applyMiddleware(
thunkMiddleware,
dispatchIdMiddleware,
() => promiseMiddleware,
loggerMiddleware
),
webWorker('/build/worker.js'), // higher-order store
createStore
); This would allow you to grab something like I'm sorry I can't explain more right now, but you can read |
No need to apologise, great to see it's already in the pipeline - HOS look very powerful. As we're just passing messages around as actions, web workers should fit nicely into the pipe.
|
Let's continue this discussion in #313. |
I haven't dug into the actual codebase itself all that much before posting this, but what would be involved to allow store handler functions to be async? This would allow stores to be handed off to their own threads, as Web Workers, for complex reduce logic.
For example, I have a huge stack of financial data, fetched into a worker thread. I repeatedly ask the worker to reduce this (fixed) data for me depending on various filtering parameters (downsampling that data for a time series graph, for instance). However, I can't pass the data back from the main thread to the worker each time as there is too much transfer overhead, so I need to keep the original unfiltered state in the worker.
Is this something middleware could support, or does that lie further up the chain?
The text was updated successfully, but these errors were encountered: