[Laszlo-user] Proposal to change how constraints are propagated
James Robey
circlecycle at gmail.com
Sat Apr 25 18:13:39 PDT 2009
Its quite clear using the sendEvent method, like you illustrate, and
although i like One Way to Do things, it reads right! So on that score
carry on. On another angle, what if i get a name from a server source
and the name is the same, but other values are different, and because
of that other operations don't occur? I think it's a iffy move. If you
do change it, it's certainly not the end of the world.
.j
On Apr 25, 2009, at 7:21 PM, Henry Minsky wrote:
>
> It seems to me that in your example, you really want to send an
> event, and setting the attribute is one step removed from that. So
> maybe the most
> clear way to implement that would be to call sendEvent directly
>
>
> <method name="update">
> canvas.onupdate.sendEvent( true);
> </method>
>
>
>
>
> On Sat, Apr 25, 2009 at 6:46 PM, jamesr <circlecycle at gmail.com> wrote:
>
>
> On Fri, Apr 17, 2009 at 6:36 PM, P T Withington <ptw at pobox.com> wrote:
> 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?
>
> I use handlers to fire functionality without actually changing any
> values. An example would be
>
> <canvas>
> <attribute name="update" type="boolean" value="false"/>
> <...>
> <handler name="onupdate" reference="canvas">
> //do something
> </handler>
> </...>
> <canvas>
>
> <method name="update">
> canvas.setAttribute('update', true);
> </method>
>
> where i expect the update handlers to get run on true regardless of
> whether they were already true before. This change would require
> that i set update to false after such an event. In my own runtime, i
> include a "touch" method which allows me to fire an event without
> having to set an explicit value, just for these type of delegate
> networks. I would toss in my two cents by saying that it would be
> nice to have one or the other available to me.
>
> there might be other methods to accomplish the same thing - i'm just
> pointing out a pattern that my code depends on, currently
>
> -james
>
>
>
> --
> Henry Minsky
> Software Architect
> hminsky at laszlosystems.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-user/attachments/20090425/19a11840/attachment-0001.html
More information about the Laszlo-user
mailing list