W3C home > Mailing lists > Public > public-device-apis@w3.org > June 2010

Re: API patterns and requirements

From: Robin Berjon <robin@robineko.com>
Date: Wed, 23 Jun 2010 12:09:17 +0200
Cc: public-device-apis@w3.org
Message-Id: <EEAE5985-BE64-491C-994A-AFD8127FF677@robineko.com>
To: Rich Tibbett <rich.tibbett@gmail.com>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:14:10 GMT