1

sorry for the crappy description but there is some class:

Event.Ticker = Class.create();

Object.extend(Event.Tick.prototype, { initialize: function (container, seconds) {

...etc..

AND this code:

new Event.Ticker("ID", 20);

so counter runs down from 20 to 0 how do I kill this at any point?

iwek
  • 1,608
  • 5
  • 16
  • 31
  • I don't know the exact internals of your Tick 'class'... will [this post](http://stackoverflow.com/questions/3969475/javascript-pause-settimeout) help? – LoveGandhi Apr 19 '11 at 02:56

1 Answers1

1

Presumably there is a way to invoke

myEvent.Stop()

which would presumably call clearInterval or whatnot, but it depends upon said interface exposed.

JavaScript is fully garbage-collected and there is no implicit (or explicit) destructors. All "cleanup" (such as Stop), if required, must be done explicitly.

There is no way to "delete" an object, only to let it become unreachable in which case the GC may reclaim ("destroy") it if it feels like it -- however both setInterval and setTimeout will maintain a strong reference to the callback which 1) will fire the callback even if the callback and/or myEvent is not strongly reachable elsewhere 2) may prevent other objects from being eligible for reclamation if they are reachable via the callback.

Happy coding.


See Garbage Collection: Reachability of an Object.