On Mon, 19 Jul 2010, Greg Brown wrote:

What about properties of properties of objects---like ${obj.prop.subprop}? If the "obj.prop" value changes, do the binding listeners get notified?

No, because those listeners have indicated that the property they care about is "subprop". They don't necessarily know or care that "prop" is referred to by another object ("obj", in this case).

I can't think of a case off the top of my head where you would actually run into this situation in the current implementation. If you can, it would help illustrate the problem.

I think the current implementation is valid. But just for comparison, it would be useful to know what Flex does in this case.

You have the flex-ibility (sorry, couldn't help myself) to define a "site" and a "chain" when creating bindings in code. The "site" is the root of the bound hierarchy. The "chain" is the sequence of properties for each of which a listener is registered. If any property in the chain changes, the bound listener will receive a notification if the last property in the chain does in fact change.

But bindings are rarely done in code and are rarely thought out that thoroughly. By default, in a root-property sequence "object.prop1.prop2.prop3..." any change in any of prop1, prop2, prop3, etc. will notify a listener. I think I can give a simple example of why this is desirable.

Suppose a component binds one of its properties to the expression "person.name.first". If first changes from "John" to "Jane" the listener will receive a notification of a change in "person.name.first" from "John" to "Jane". If name changes from {first: "John", last: "Doe"} to {first: "Jane", last: "Doe"}, shouldn't the listener know the first name changed? Strictly speaking, the original name's "first" property didn't change---it's still "John".

Similarly, if person is reassigned from person1 to person2 and they have different first names, etc. If this person is a data model backing a form, and the person is changed wholesale, any "first name" labels/inputs/validators/parsers/what-have-you need to know.

Cheers,

Michael

Reply via email to