[Glimmer 2] Two-way binding support#13502
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)) { |
|
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).