[whatwg] Polling APIs in JavaScript vs Callbacks
Tab Atkins Jr.
jackalmage at gmail.com
Sat Feb 9 08:43:11 PST 2013
On Thu, Feb 7, 2013 at 6:32 PM, Glenn Maynard <glenn at zewt.org> wrote:
> This is just to say: callbacks are the pattern on on the platform, not
> polling, and WebGL should follow that pattern, not go its own way and make
> up its own conventions. If people don't understand why the platform's
> conventions are what they are, and think they should be something else,
> please encourage them to come here and discuss it--not to try to make WebGL
> its own isolated island. That's damaging to WebGL and the platform as a
> whole.
Completely correct, and I agree.
That said, there *are* still some isolated use-cases for polling. ^_^
When an event-based approach would potentially deliver far too many
events, with separation between them perhaps less than 1ms, exposing a
polling-based API instead can be useful. I haven't followed the
Gamepad API lately, but I know this was at least considered for some
of the types of feedback, such as the exact position of joysticks or
pressure on buttons, both of which can change very rapidly in
realistic scenarios.
Outside of these kinds of constraints, though, polling is a no-no, for
the reasons that Glenn gives.
~TJ
More information about the whatwg
mailing list