<div dir="ltr"><div class="gmail_quote">On Thu, Oct 2, 2008 at 5:32 PM, Ojan Vafai <span dir="ltr">&lt;<a href="mailto:ojan@chromium.org">ojan@chromium.org</a>&gt;</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">&lt;<a href="mailto:aa@google.com" target="_blank">aa@google.com</a>&gt;</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 &lt;<a href="mailto:mjs@apple.com" target="_blank">mjs@apple.com</a>&gt; wrote:<br>
&gt; I don&#39;t really like the overengineered version. I like the &quot;fairly<br>
&gt; minimalist&quot; version best, but is there anything from the<br>
&gt; overengineered version that should be added to it?<br>
<br>
</div>I like the &quot;fairly minimalist&quot; 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 &quot;overengineered&quot; 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&nbsp;callback);<br><br>interface Timer {<br>&nbsp; &nbsp; void stop();</span></div></div><div><span style="border-collapse:collapse">&nbsp;&nbsp; &nbsp;void resume();</span></div>

<div><span style="border-collapse:collapse">&nbsp;&nbsp; &nbsp;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&#39;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 &nbsp;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. &nbsp;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>