-
Notifications
You must be signed in to change notification settings - Fork 543
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
two way binding to struct fields #556
Comments
At the heart of the issue lies that the binding for the checked property is destroyed:
Initially the binding
and the assignment to |
We would somehow need to support two ways binding with model properties this is not easy because the runtime really expect properties so they can be merged into one property. |
I've begun prototyping an approach that tries to detect two-way bindings in model data structures, synthesise a property for it and update it in the model update function. Diagnostics wise it might be interesting to also have a pass that tries to detect cases where we know that a property has a binding and is written to somewhere else - in order to issue a warning that perhaps a two-way binding is desired. |
I think we really need to be able to declare property are meant to be "readonly" or something (like the For example the compiler can't know if the NativeCheckBox assignthe checked property. However we already annotate some property as being set. But it'd be better to be exlicit about it i think. |
We discussed the two-way bindings separately a bit further and with regards to the model we could implement tow-way bindings for model data by using the existing callback functionality of |
@ogoffart I was just hit by this as well. Is there some suggested workaround for now? I can't control the |
It depends a bit of what you're doing. CheckBox {
text: {
checked = the_property; // <- Ugly workaround right there
" Check me ";
}
checked: the_property;
toggled => {
the_property = checked;
}
} This works because the |
@ogoffart I see. I worked around by using my local fork and slightly modifying |
Closing this as a duplicate of #814 |
Modify the Todo example like this:
Then when running, pressing the "remove all done" button will toggle all todos. That works the first time. Then turn off a few toggles in the UI and press the "remove all done" button again.
Expected Result: All todos are checked again.
Actual Result: Nothing changes in the UI.
The text was updated successfully, but these errors were encountered: