On 2010-07-14, at 00:21, Max Carlson wrote:
> 2) I don't understand this comment in layout.lzx#94:
>
>>> // ignore special default value of 2 until __parentInit();
> especially given this change in construct:
>
>>> // set as early as possible - can't wait for setter to be called
>>> this.locked = args.locked;
> Does every layout get a `locked` init arg?
>
> I updated to address this. Now, construct() sets to 2, so any args can
> override.
Two more questions:
1) I'm clearly missing something on this 'locked = 2' logic.
a) Locked is defaulted to 2, so, you don't need to set it to 2 in construct.
b) I see there is a delegate that runs when the parent is inited, that says "if
lock is still 2, unlock the layout".
c) But the setter doesn't look for the magic 2 value at all. So, if I created
a layout with an initarg 'locked', it would subvert this "Adam magic".
d) How could the layout not be inited and the parent inited, since for a parent
to be inited, all its children must be? In which case, we don't need a
delegate to defer reset when the parent does get inited.
---
Why can't we just be straight about this and say what we mean (i.e., that we
don't run the layout if the parent is not yet inited, because it would be a
waste of effort -- we don't know all our siblings yet):
<method name="reset" args="e = null ">
// Don't if we are locked, or our parent is not inited yet
if ( this.locked || (! this.parent.inited)) { return; }
//defalt behavior on reset is to update
this.update( e );
</method>
<handler name="oninited" reference="this.parent">
this.reset();
</handler>
That seems much more straightforward to me, and you don't have to do any
dynamic delegate creation.
2) Should `reset` actually be a public method? It is what enforces the 'lock'
logic. If some subclass overrides it, that subclass needs to enforce the same
logic. It seems to me that it should be sufficient for subclasses to be able
to override `update`.