I really like the idea! Aaron - not sure this is quite the same - in
your code the attacher needs to say - "this one should be latched" -
while Agroism's suggestion moves the responsibility to the dispatcher
(which I find to be better suiting).
I do find the fireOnce name missleading. Maybe it should be a pseudo
event on fireEvent. Something like:
this.fireEvent('load:latched',args);
On 7/22/11, Aaron Newton <[email protected]> wrote:
> I authored something very similar a while back called Event.Latch:
>
> https://github.com/anutron/art-widgets/blob/master/Source/Utilities/Event.Latch.js
>
> (in programming, a "latch" is a condition that starts out false but once set
> to true remains so forever)
>
> On Fri, Jul 22, 2011 at 1:05 AM, Agroism <[email protected]> wrote:
>
>> If an event is fired through this special 'fireOnce' method, then all
>> functions that are attached to that key/event name will be fired
>> immediately.
>>
>> Chase Wilson
>> Phone Mail. :)
>>
>> On Jul 22, 2011, at 12:36 AM, "Steve Onnis" <[email protected]>
>> wrote:
>>
>> So you are saying, if you add events to something and the event has
>> already
>> fired, if you add new functions to the same event, you just want them to
>> fire immediately rather than be qued?****
>>
>> ** **
>>
>> *From:* jiggliemon [mailto:[email protected]]
>> *Sent:* Friday, 22 July 2011 4:46 PM
>> *To:* <[email protected]>[email protected]
>> *Subject:* Re: RE: [Moo] New method to Events class****
>>
>> ** **
>>
>> The point is that when the dom is ready, it's ready (why set up a new
>> function queue when that function can be fired right away), and thanks to
>> how the domready event is written, if you attempt to add a function to the
>> domready queue post `domready` or after that event has already fired, it
>> bypasses a queue, and fired that event right away:****
>>
>> ** **
>>
>> http://jsfiddle.net/jiggliemon/uN6vh/****
>>
>> ** **
>>
>> It would make sense to mimic that same functionality with the core
>> 'Events'
>> class.****
>>
>> ** **
>>
>> - Chase****
>>
>>
>
--
Arieh Glazer
אריה גלזר
052-5348-561
http://www.arieh.co.il
http://www.link-wd.co.il