-
Notifications
You must be signed in to change notification settings - Fork 330
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
For input
elements, change
event callback happens before data model is updated?
#668
Comments
Right, so both of these data controllers effectively add an event listener for the change event. I believe in whichever order they are declared, or actually it might be a bit arbitrary due to unordered maps being involved. And then they just do their thing in that order when the change event is emitted. For the data views, we are being a lot more comprehensive to give everything a defined update order. However, I believe we don't really do anything like this for the data controllers (value and event). For controllers, I guess it makes more sense to define an initialization order, rather than an update order. So yeah, I think it makes sense to always initialize the value controller first, so that it gets to the event first. At least I can't really think of any downsides. |
Thanks for the explanation. I'd like to talk a bit about the background. I'm trying to complete the 7 GUIs challenge using RmlUi, and the following use cases requires to update the value first:
And I didn't found a use case that requires to update the value after a |
Oh, interesting. Haven't come across this project before. Definitely some interesting challenges. I am fully on board with making this change, the use cases here are convincing to me. |
For reference, here's an old comment describing essentially the same issue, and also a note that |
I've created an example in the
tutorial
directory. Here are the important bits:index.rml
:main.cpp
:If we run this in a terminal:
The same is tested on
select
element and the behavior is similar.So it seems the callback is called before data model is updated. What should I do if I need the updated data in such callback?
Thanks!
The text was updated successfully, but these errors were encountered: