Dave, I think you are right that my implementation does cause a memory leak over time. It interesting that I can't find a single example of someone calling dispose on an object like this. The google code for disposable hold a global reference to all disposable instances and only removes when dispose it called. It might be better to use the static function goog.Timer.callOnce(listener, opt_delay, opt_handler).
Creighton Kirkendall On Jan 16, 6:25 pm, Dave Sann <daves...@gmail.com> wrote: > If you use something like goog.async.Delay, or other goog closure libs that > produce objects that have a dispose method, > > Is it imperative that .dispose is called when you are done with this object? > What happens if not? memory leak? > How do you manage this if you are passing such objects around in function > closures or other structures > where you may not (want to) know exactly when this may be no longer > required? > > I was looking at this thread - and the conversion of js/setTimeout to > goog.async.Delay, along with the enfocus implementation > > https://groups.google.com/d/msg/clojure/epHVbmcNzgs/3pVyS_AKCYUJ > > from enfocus: > > (defn setTimeout [func ttime] > (. (new goog.async.Delay func ttime) (start))) > > what about functions such as this? > > (defn repeat-with-timeout > [f t] > (let [stop (f)] > (if-not (= true stop) > (js/setTimeout #(repeat-with-timeout f t) t)))) > > Cheers > > Dave -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en