-
Notifications
You must be signed in to change notification settings - Fork 32
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
Pass through dispatch action to batch function #13
base: master
Are you sure you want to change the base?
Conversation
Having the action available at the batching function level is important for calculating batch exclusion based on action type.
I just saw a second PR from January un-merged that does exactly the same thing. Are there any issues with this? |
Looking into getting this PR merged soon. Just evaluating the impact future redux store enhancer api changes might have on this: |
I was just about to implement this exact same functionality when I came across this PR. @tappleby |
@tappleby Any updates here? I understand that this is something that the Redux team isn't offering positive feedback in this direction based on the linked issues, but I'm struggling to see how this lib can be used without receiving the |
I also started implementing this same functionality, then I forked @sagar-sm's version - but then I realized that this stuff is pretty easy to compose to get whatever behavior you need (in my case, at the expense of some global mutable variables - but not terribly hacky, you could easily encapsulate them if you wanted). Here's what I did: batching/state.js
batching/enhancer.js
batching/middleware.js
Once you stick the middleware and the enhancer in the right place, you can imperatively persist store changes to your components, e.g.:
This suited my needs just fine, but isn't really ideal since the store's state should probably be in a consistent state at all times, but unfortunately we didn't develop the right abstractions to do that for our app until it was too late and a refactor had become expensive. Hopefully this helps someone else out (I noticed sagar-sm's fork has 22 forks of its own) - and of course, my implementation is only like 20 lines, so you could do something very different in the middleware to suit your needs. |
Having the action available at the batching function level is important for calculating batch exclusion based on action type. This is important for things like transactional batching triggered by specific actions which is a use case we came across.