On 6/10/11 1:18 , Frank Grimm wrote:
The @Ignore comment on org.qi4j.runtime.property.PropertyTest ("This is
an incorrect satisfiedBy case. [...]") seems to indicate that
SideEffects on Properties might not work right now.?

If this is the case, is there another Qi4j-ish way to get notified about
property value changes? I'm intending to update UI elements whenever the
underlying Composites change state.

Right, we don't support this directly in Qi4j right now, and I agree that there are perfectly valid cases where one would want to do what you're asking for, at least for transient composites (values and entities, not so much).

The only workarounds I can think of for now are these:
1) When a Property is set constraints are checked first, so you could implement a Constraint that always passes, but which delegates the new value to whatever mechanism you use to detect changes 2) Implement a Concern for Property<> methods that wrap the Property with something that propagates the get/set calls accordingly. Something like:
@AppliesTo( { PropertyMixin.PropertyFilter.class } )
public class PropertyNotificationConcern
  extends GenericConcern
{
    public Object invoke( Object proxy, Method method, Object[] args )
        throws Throwable
    {
        final Property property = (Property)next.invoke(proxy,method,args);
        return new ComputedPropertyInstance<Object>(property)
        {
          public Object get()
          {
            // Notify here
            return property.get();
          }

          public void set(Object object)
          {
            property.set(object);
            // Notify here
          }
        }
    }
}
---
Something like that should work reasonably well. You could either send events to an event bus in your app, or have interested parties register themselves in the metaInfo() of the property.

/Rickard

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to