-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[Glimmer 2] Two-way binding support #13502
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
ae3e4b0 to
715b38d
Compare
|
Follow-up TODO: Implement The Similarly, we also need |
|
The twiddle shows three different invocations: Notice that there are no
Clicking the increment buttons for the first invocation does not raise an error nor produce strange behaviour. Incrementing foo in the second invocation will set foo in the third invocation to the same value (reset both external value and then increment the third foo three times. When incrementing the second foo once, the third foo will have the value 2 instead of 4 since the binding is shared). Incrementing foo in the third invocation will have no side effects. Incrementing Funny thing, incrementing the value of |
| var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; | ||
|
|
||
| if (!watching) { | ||
| if (m && !m.isInitialized(obj)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
much more clear
|
Overall this looks good to me. |
This commit restructures some of the more arcane parts of ember-metal's observer system. It eliminates some special casing around `length`, which isn't necessary anymore but complicates the overall abstraction of observable properties. Relatedly, it also finishes implementing PROPERTY_DID_CHANGE, which now executes reliably any time an observer would have fired. You can think of it as an always-on observer if it's present on an object. Glimmer 2 curly components use this hook to propagate `set`s on components back to their original bindings (if the bindings are present). This commit also implements two way bindings in Glimmer 2, by making PropertyReferences implement an `UPDATE` method. If that method is present, it is used to propagate changes upwards (otherwise, an exception is thrown).
This commit restructures some of the more arcane parts of ember-metal's observer system.
It eliminates some special casing around
length, which isn't necessary anymore but complicates the overall abstraction of observable properties.Relatedly, it also finishes implementing PROPERTY_DID_CHANGE, which now executes reliably any time an observer would have fired. You can think of it as an always-on observer if it's present on an object. Glimmer 2 curly components use this hook to propagate
sets on components back to their original bindings (if the bindings are present).This commit also implements two way bindings in Glimmer 2, by making PropertyReferences implement an
UPDATEmethod. If that method is present, it is used to propagate changes upwards (otherwise, an exception is thrown).