Newsgroups: comp.lang.javascript
From: "Richard Cornford" <Rich...@litotes.demon.co.uk>
Date: Thu, 24 Apr 2003 18:10:56 +0100
Local: Thurs, Apr 24 2003 1:10 pm
Subject: Re: closures, what are they good for?
Richard Cornford wrote in message ... <snip> >.... It seems that it would often be a good idea to include, and That of course requires that multiple objects or classes have methods >use, explicit 'destroy' functions with DHTML and ActiveX based >JavaScript objects that use closures. To free up any references >from JavaScript objects before/as a page unloads. called by the window.onunload event. Not a problem if the browser supports addEventListener. However, as the subject of this thread is uses that closures may be put to, this closure offering from Yep might of interest:- <URL: function _E(obj, evt, func){ } Unfortunately it might also require a Function.prototype.apply emulation on older IE versions, but if that is only for use with event handlers it could be a very simple emulation. Yep has also kept this function very general and is making no consideration of return values. That would not be a problem when used with window.onunload as not return values are relevant. The - apply - method would probably also not be necessary with the window.onunload event as it would not matter whether the _f and _g functions where executed in the global context because that is the window anyway. So, maybe (untested):- function _E(func){ } Thus (and assuming that any HTML defined onunload handlers are already set up and no other script is going to directly assign window.onunload) each instance can arrange that its own destroy/finalize method is called with the onunload event. Based on the recent discussion of JavaScript static (and particularly, Richard. You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||