-
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
Adding exceptions #16
Comments
So our old batcher would work something like: let rafID;
export default function rafUpdateBatcher(notify) {
if (rafID) return;
rafID = raf(() => {
rafID = null;
notify();
});
}
const store = createStore(reducer, initialState, batchedSubscribe(rafUpdateBatcher)); Now I'd like to add exceptions, for example like: let rafID;
export default function rafUpdateBatcher(notify, action, getState) {
// batch exceptions
switch(action.type) {
case ADD_NOW:
notify();
raf.cancel(rafID)
rafID = null;
return;
}
if (rafID) return;
rafID = raf(() => {
rafID = null;
notify();
});
}
const store = createStore(reducer, initialState, batchedSubscribe(rafUpdateBatcher)); |
Hello @peteruithoven , I was just looking for how to add exceptions to the enhancers and I found this thread. I don't really understand how to set some exceptions and I really need those because I'm using redux-form and I don't want its changes to debounce :) My current script looks like: Thanks in advance for your help! |
As mentioned in reduxjs/redux#125 (comment) there are issues when batching updates and using controlled components. For example when using controlled input fields, when the user edits something (not at the end of the line / text) the cursor always jumps to the end.
For this reason I'd like to add exceptions to which notifications are batched or have a way to enable / disable the batcher.
I'm going to work on a PR, but comments are more than welcome.
I'm also reading through: petehunt/react-raf-batching#8
The text was updated successfully, but these errors were encountered: