-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Return a promise from handleChange #208
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
Conversation
Obviously can update tests and docs if no one is opposed to this. |
Two thoughts:
|
@gaearon The macro problem I am trying to solve is simply knowing when react is finished flushing changes to the DOM. Unfortunately the only affordance to do that is through a callback in every call to |
For the purpose of discussion, here’s a more detailed explanation of why this is necessary in some use cases: Assume that you are trying to create a WYSIWYG text editor for the browser (fairly common and painful endeavor). The state at any given moment is primarily composed of two things:
At first glance you might wonder why it is important to keep the text selection in state. The answer is simple: undo/redo. When a user triggers an undo or redo action, we not only need to restore the document to the previous state, we also need to restore the text selection to the previous state. It is important in this case that we fully restore the document state to the DOM before trying to restore the text selection. It should be obvious that trying to restore a selection of something that doesn’t yet exist on the page is problematic. Hence the need to know when the DOM has been fully rendered within the normal action emit/listener/render loop provided by Redux. After the DOM has been fully rendered, we can do the manual task of restoring the selection state on top of the DOM. As far as I can tell, the current Redux and @gaearon do you see a different approach to this that would still allow for using redux and react-redux? Are there other scenarios in React or React-Native or even angular which might require knowing when changes to state have been fully flushed to the UI? |
I understand your use case. I don't want to complicate |
Resolves when React rendering is complete. See reduxjs/redux#1096 for related change to Redux core.
Enables callers of dispatch to run a callback when all React rendering has been completed.
Thoughts?