|
Re: recursive function + event : is this legal/supported ?: msg#00062mozilla.devel.dom
> Why not, you need to make sure that the recursion is stopped somewhere > otherwise you get a stack overflow but besides that it should work. Basically I am trying to understand the longevity/scope of object variables when DEPENDENT on an async (onload) events. OK lets forget recursion for a moment and just consider a loop setting the src attribute of a number of content buffers. The request object has its id set to to the loop counter. var request = new Object for (i=0;i<sources;i++) { request.id=i buffers[i].addEventListener("load", function() loadhandler(request)}, true); buffers[i].setAttribute('src',file://path+i+".xml") } Unlike synchrous loads, I cannot rely on the correct counter value of request.id being passed because the loop is likely to be set to 'sources' rather than the specific iteration 'i' before the even first load event event takes place. So I assume I must create a new instance of a request object each time for (i=0;i<composite.datasources;i++) { var request = new Object request.id=i buffers[i].addEventListener("load", function() loadhandler(request)}, true); buffers[i].setAttribute('src',filepath+i+".filetype) } Q1. If I want to delete these spawned objects, I simply do this in the loadhandler by setting the passed object to null. function loadhandler(request) { // kill "instance" of request object request=null } Q2. but does setting each request object to null also free up ALL "associated array" properties subsequently created ?? function loadhandler(request) { // a) create temp properties for imds source request.imds = Components.classes[rdf_memories].createInstance(); request.triples =request.imds.QueryInterface(Components.interfaces.nsIRDFDataSource); // b) create request.triples assertions (using data from iframe buffer) // c) if request object is set to null request=null } In otherwords should any request.triples be IMPLICITLY purged when request is set to null or do they need to be freed up EXPLICITLY using function like Unassert()? |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | website hosting: 00062, forall2see_2000@xxxxxxxxx |
|---|---|
| Next by Date: | Re: recursive function + event : is this legal/supported ?: 00062, Boris Zbarsky |
| Previous by Thread: | Re: recursive function + event : is this legal/supported ?i: 00062, Martin Honnen |
| Next by Thread: | Re: recursive function + event : is this legal/supported ?: 00062, Boris Zbarsky |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |