So a couple of hours turned into all day. That's just my life these days. We
have a big demo we're getting ready for on Wed. (I can't wait until we can
release some of this stuff)

Anyway, I'll have to try again to write something more concrete for you
later in the week. Feel free to badger me for it.

Basic premise though (mind you this pure pseudo): (also, I'm thinking a
special EventGC is not even needed, just give the wrapper class a dispose
method and use the DisposableGC)

EventObserverWrapper = Class {
observers = [],
observe: function(element, eventName, handler, {any other params to make a
code complete wrap})
{
observers.push(
{
element: element,
eventName: eventName,
handler: handler
});
Event.observe(element, eventName, handler);
},
dispose: function()
{
$A(this.observers).each(function(observer)
{
Event.stopObserving(observer.element, observer.elementName, observer.handler
);
observer = null; //de-reference to remove chances of circular leaks
});
this.observers = null;
}
}

someClass = Class {
eventCache: new EventObserverWrapper(),
initialize: function(someElement)
{
eventCache.observe(someElemtent, "click", function() { alert("clicked"); }
);
doSomething();
this.arrayOfDraggablesAndAllKindsOfStuffWithDisposeMethods = [...objects
galore...just an example...];
},
dispose: function()
{
$A(this.arrayOfDraggablesAndAllKindsOfStuffWithDisposeMethods
).each(function(obj)
{
globalGC.add(obj);
}
this.arrayOfDraggablesAndAllKindsOfStuffWithDisposeMethods = null;

globalGC.add(this.eventCache);
this.eventCache = null;
}
}

...and even extend the DisposableGC a bit to handle auto queuing the
children items. The end result is a pile of objects in the GC, each disposed
every XXX milliseconds, leaving the user to continue interacting with the
application.

DisposableGC.cleanup = function(obj)
{
for (var p in obj)
{
if (typeof obj[p] == "object" && obj[p].dispose && typeof obj[p].dispose ==
"function")
this.add(obj[p]);
}

if (obj.dispose && typeof obj.dispose == "function")
obj.dispose();
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to