On 2009-04-28, at 16:38EDT, Max Carlson wrote:
P T Withington wrote:
On 2009-04-28, at 16:16EDT, Max Carlson wrote:
So all you have to do is make your own declared event instance to
initialize your event to, you don't have to make a separate class.
How would this work in declarative syntax?
Give me an example of where you would need it and I will tell you.
The only places I could think of using this is internally when
connecting events to the runtime, because the runtime only accepts
callbacks and you would like to not register a callback that is
going to be a no-op because the corresponding event is not ready.
In declarative code, setAttribute is already optimized to do
nothing if the corresponding event is not ready.
Well, just in case, we could do something like this:
<class name="myFunnyEventine" extends="event">
<method name="onReadyChange" args="newValue">
if (newValue) {
// you have listeners...
} else {
// now you don't...
}
</method>
</class>
<event name="sometimesMaybe" type="myFunnyEventine" />
And the event compiler would compile that to:
var sometimesMaybe = new LzDeclaredEvent(myFunnyEventime);
And you're done. Power tool, use with extreme caution.
---
Anyone got a better name than `onReadyChange`?