via the object model abstraction layer we have in our framework - so at that
level it's a manual call, but by using the framework it's managed and for
all intents and purposes automatic via a custom app garbage collector. Then
again, we have an XML layer to represent widgets as finite state machines
and manage application flow declaratively - so I'm talking about quite a few
levels removed from the average prototype application...
Just because js doesn't support something doesn't mean it's not possible.
It's all about abstraction of common tasks.
Basically, you want to start by creating something like a "Disposable"
abstract class that your objects inherit from (or an interface that they
implement) that includes a "dispose()" method (we use interfaces here for
true contractual development)... then you implement the specific dispose
logic on a per class basis to cleanup resources. Then, yes, at first it's a
manual process of making sure dispose() gets called when it needs to be
called. If you end up, like we often do, following a progression of
abstracting away common tasks as you get sick of doing them over and over
again manually, you eventually end up with some type of automatic garbage
collection (that still assumes a dispose method exists on the object public
interface).
On 9/24/07, Jeff Watkins <[EMAIL PROTECTED]> wrote:
>
>
> How would you implement a destroy or destructor function since
> JavaScript doesn't support it? Do you manually call the method?
>
> On Sep 24, 2007, at 11:24 AM, Les wrote:
>
> >
> > Ryan,
> >
> > Did you notice that each OpenLayers class has a destructor (destroy)
> > and a property denoting the class name?
> >
> > I don't see such a destructor in Prototype or Dojo, see below:
> >
> > OpenLayers.Map = OpenLayers.Class({
> > ....
> > initialize: function (div, options) {
> > },
> > ....
> > destroy:function() {
> > },
> > CLASS_NAME: "OpenLayers.Map"
> > });
> >
> >
> > >
>
>
> >
>
--
Ryan Gahl
Manager, Senior Software Engineer
Nth Penguin, LLC
http://www.nthpenguin.com
--
Architect
WebWidgetry.com / MashupStudio.com
Future Home of the World's First Complete Web Platform
--
Inquire: 1-262-951-6727
Blog: http://www.someElement.com
LinkedIn Profile: http://www.linkedin.com/in/ryangahl
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---