[webkit-dev] High Resolution Timer API proposal(s)

Peter Speck speck at vitality.dk
Fri Oct 3 10:24:38 PDT 2008


On 03/10/2008, at 19:09, Mike Belshe wrote:

> I'm not opposed to any of this; and the new API is definitely  
> nicer.  I'll bring up a devil's advocate point.  One thing I hate is  
> the Microsoft-style smorgasboard of APIs.  When you want to start a  
> timer, you have 6 to choose from, and I hope we can avoid similar  
> problems in the DOM.  If keeping the number of APIs is a worthy  
> goal, we could just augment the existing API in a backward  
> comaptible way:
>
>     setTimeout(callback, milliseconds, protect_against_cpu_looping =  
> true)
>
> Example to set a 1us timer:
>
>   setTimeout("foo()", 0.001, false)


And future extensions would add even more parameters.

The Google Map API uses an object for such extra parameters, e.g.

setTimeout("foo()", 0.001, { throttle:false, runInBackground:true });

This would allow for future extensions without adding new methods/ 
classes; without having to add yet another API method.


----
    - Peter Speck




More information about the webkit-dev mailing list