Hi Lebrun,
 

> Is there a mean to detect that a tiddler is about to close (in widget's 
> code) ?
> In my widget, there is an animation with a periodic function launched 
> every xx ms with setTimeout or with requestAnimationFrame().
> I would like to stop that function when tiddler closes, to free CPU if 
> function is heavy or numerous widget instances. Ideally with an event 
> listner.
>
>
I had the same problem. Unfortunately, no destructors exist. What you can 
do is to check if the parent dom node is still part of the document in your 
listener head. So next time the handler is called your listener deletes 
itself.

Consider this:

  TaskGraphWidget.prototype.handleResizeEvent = function(event) {

    if(!document.body.contains(this.parentDomNode)) {
      window.removeEventListener("resize", this.handleResizeEvent);
      return;
    }
    
   ... otherwise code
    
  };


Hope it helps

Felix

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.

Reply via email to