W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2008

Re: [webkit-dev] Proposed Timer API

From: Geoffrey Garen <ggaren@apple.com>
Date: Fri, 3 Oct 2008 11:15:49 -0700
Cc: Maciej Stachowiak <mjs@apple.com>, WebKit-Dev Development <webkit-dev@lists.webkit.org>, public-webapps@w3.org
Message-Id: <8AA2A2C0-6261-4AFD-83BC-417881A1B433@apple.com>
To: Chris Marrin <cmarrin@apple.com>

Hi Chris.

> I really like the idea of a Timer object. It would allow you to
> separate creation from starting, allows you to pause and add other
> API's to the interface. Can the constructor be used to simplify the
> creation:
>     var t = new Timer(0, false, function() { ...});
> which would start the timer immediately, as in your example.

I think Maciej has made a convincing case that "new Timer" is a bit  
too coy about the fact that the timer is actually starting.

> Or you could do:
>     var t = new Timer(function() { ... });
>     ...
>     t.startOneShot(1.76);

I like your suggestion of adding "startOneShot" (and  
"startRepeating"?) to the API. I think it would improve clarity over a  
bool parameter specifying whether the timer repeats.

To create a Timer that isn't scheduled to fire:

new Timer(...)

To create a Timer that is scheduled to fire:

new Timer(...).startOneShot(...)
new Timer(...).startRepeating(...)

Or, if we don't like constructors:


> And you could easily add animation or media API's for synchronization:
>     var t = new Timer(1.76, function() { ... }); // when the timer is
> triggered, it will run for 1.76 seconds
>     var transition = window.getTransitionForElement(element, "left");
>     transition.trigger(t);
>     ...
>     element.style.left = "100px";
> This would cause the timer to start when the left transition starts
> and fire its event 1.76 seconds later.

This would be really cool!

Received on Friday, 3 October 2008 18:16:30 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:12 UTC