Re: API patterns and requirements

On Jun 17, 2010, at 16:23 , Rich Tibbett wrote:
> The following pattern, as used in the IndexedDB specification [1], would be applied to System-Info and Contacts APIs:
> 
> SystemInfo API example:
> 
> navigator.system.request.onsuccess = function() {
>     var batteries = navigator.system.request.result; 
>     for(i in batteries) alert(batteries[i].level);
> };
> navigator.system.get('Power');

Access serialisation is a valid concern, but solving it with global handlers is the wrong solution. The solution you propose means that all code that needs to access the API will need to coordinate with one another so as to avoid overwriting, and that a single faulty library can break it for everyone. Not good. It's a very common issue with window.onload — I'd really rather we learnt from that mistake.

I like Mike's suggestion of aborting the previous request. It's simple, it's what XHR does, it can be described rather easily.

--
Robin Berjon
  robineko — hired gun, higher standards
  http://robineko.com/

Received on Wednesday, 23 June 2010 10:09:49 UTC