On 2007-07-12, at 07:29 EDT, Robin Sheat wrote:

On Thursday 12 July 2007 22:51:14 P T Withington wrote:
Note that in 4.x, handlers on the instance being constructed that
would be triggered due to setting initial values into the instance
are deferred until _all_ the initial values are set -- so the
handlers will not see a partially constructed instance.
I'm using 3.3 (I tried writing the app for 4, but there was a bug I couldn't figure out (I think to do with the stretch attribute on view), and I'm under a time constraint. When I get this app finished and working in 3.3, I'll go
back and try to reproduce it)

My issue is that I have handlers set that report back to the server when certain attributes change, and of course on initialisation, there is a flurry of events that I want to ignore (being the initial data setting). I was hoping that it would always be the case that attributes would be set, then isinited set, or at least that my oninit handler would be called, however it
seems that neither of those are reliable.

isinited should be false initially. It is set right before calling init and sending oninit, because it is used internally to prevent init being called more than once.

My current, very ugly, workaround
is to simply count the number of events: if there are 4 attributes, ignore
the first 4 events. Not nice, but it means that it works.

Maybe a better thing would be to create your own flag to silence the handlers and set that flag to true when you get the oninit event?

(I have learnt an important lesson though, when writing your first significant Laszlo app, keep working until it becomes unmaintainable, and then start again using all the knowledge you picked up the first time around - my new
one is about 2/3rds the size, faster, much more maintainable, has more
features, and has taken me about three weeks (compared to a couple of months
the first time around) :)

Good advice for any project. The title of one of the chapters in Fred Brooks's "Mythical Man Month" is "Plan to throw one away (you will anyway)".

Reply via email to