<div dir="ltr"><div class="gmail_quote">On Thu, Oct 2, 2008 at 5:32 PM, Ojan Vafai <span dir="ltr"><<a href="mailto:ojan@chromium.org">ojan@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div dir="ltr"><div class="gmail_quote"><div class="Ih2E3d">On Thu, Oct 2, 2008 at 5:16 PM, Aaron Boodman <span dir="ltr"><<a href="mailto:aa@google.com" target="_blank">aa@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Thu, Oct 2, 2008 at 5:05 PM, Maciej Stachowiak <<a href="mailto:mjs@apple.com" target="_blank">mjs@apple.com</a>> wrote:<br>
> I don't really like the overengineered version. I like the "fairly<br>
> minimalist" version best, but is there anything from the<br>
> overengineered version that should be added to it?<br>
<br>
</div>I like the "fairly minimalist" version best as well.<br>
<br>
The stop() method does seem a little lonely on the Timer interface all<br>
by itself.<br>
<br>
If others think any other members from the "overengineered" version<br>
are important I would welcome them to keep stop() company.<br></blockquote><div><br></div></div><span style="border-collapse:collapse"><div>+1. My ideal would be the following:</div><div class="Ih2E3d"><div><br></div><div>
<span style="border-collapse:collapse">Timer startTimer(double delayInSeconds, bool repeating, Function callback);<br><br>interface Timer {<br> void stop();</span></div></div><div><span style="border-collapse:collapse"> void resume();</span></div>
<div><span style="border-collapse:collapse"> void setDelay(double delayInSeconds);<br>}</span></div><div><span style="border-collapse:collapse"><br></span></div><div><span style="border-collapse:collapse">That would cover the majority of cases I've seen in real-world javascript code. The argument for setDelay is wanting to be able to tweak the delay on the fly (e.g. Google Page Creator has autosave code that gets a response from the server with a longer delay time when the server is overloaded).</span></div>
<div></div></span></div></div></blockquote><div><br></div><div>That is a good use case. Adjusting the delay can often be optimized down to just re-positioning the already pending timeout in a priority queue.</div><div><br>
</div><div>Would it make sense for resume and setDelay to be combined as a restart(delayInSeconds) method, perhaps where delayInSeconds is an optional parameter?</div><div><br></div><div>-Darin</div></div></div>