[Laszlo-dev] Proposal to change how constraints are propagated

P T Withington ptw at pobox.com
Fri Apr 17 15:36:32 PDT 2009


I'm working on http://jira.openlaszlo.org/jira/browse/LPP-8058 to  
reduce the number of extraneous events sent by implementing the  
following optimization:

If an attribute is constrained, and the values the constraint depends  
on change, but the result of the constraint does _not_ change, then  
the attribute will not be updated (to the identical value) and, more  
importantly, no `on` event will be sent.  The change can be  
demonstrated by considering the following:

<canvas layout="axis: x; spacing: 5" debug="true">
     <attribute name="jay" value="2" />
     <handler name="onjay">Debug.info("onjay")</handler>
     <attribute name="kay" value="4" />
     <handler name="onkay">Debug.info("onkay")</handler>
     <attribute name="jaykay" value="${jay*kay}" />
     <handler name="onjaykay">
        Debug.info("onjaykay: %d * %d = %d", jay, kay, jaykay);
     </handler>
     <button onclick="canvas.setAttribute('jay', canvas.jay)">Same</ 
button>
     <button onclick="canvas.setAttribute('jay', canvas.jay +  
1)">Different</button>
</canvas>

In the current system, setting `jay` will _always_ cause `jaykay` to  
be updated, and for there to be an `onjaykay` event.  In the proposed  
change, setting `jay` to the same value, will cause an `onjay` event,  
but the constraint on `jaykay` will have the same result, so `jaykay`  
will _not_ be updated and there will be _no_ `onjaykay` event sent.

Comments?  Questions?



More information about the Laszlo-dev mailing list