W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2010

Re: [IndexedDB] API feedback

From: Nikunj Mehta <nikunj@o-micron.com>
Date: Sat, 13 Mar 2010 01:44:31 -0800
Cc: Jeremy Orlow <jorlow@chromium.org>, Kris Zyp <kris@sitepen.com>, Shawn Wilsher <sdwilsh@mozilla.com>, public-webapps WG <public-webapps@w3.org>, Arun Ranganathan <aranganathan@mozilla.com>, Jonas Sicking <sicking@mozilla.com>
Message-Id: <35BFADDA-4181-4B9B-A6E0-E9D53B31B2D7@o-micron.com>
To: Aaron Boodman <aa@google.com>

On Mar 12, 2010, at 9:05 AM, Aaron Boodman wrote:

> Looking at just this snip:
>
> function findFred(db) {
>  db.request.onsuccess = function() {
>    var index = db.request.result;
>    index.request.onsuccess = function() {
>      var matching = index.request.result;
>      if (matching)
>        report(matching.isbn, matching.name, matching.author);
>      else
>        report(null);
>    }
>    index.get('fred');
>  }
>  db.openIndex('BookAuthor');
> }
>
> This example is hard to read where the callback is setup before the
> call like this. Without making any API changes, I think you could
> improve things:
>
> db.openIndex('BookAuthor');
> db.request.onsuccess = function() {
>  ...
> };
>
> You just have to make sure that the API guarantees that
> onsuccess/onfailure will always be called in a separate event, which
> is important anyway for consistency.

This seems like a light-weight enough requirement that can improve  
program comprehension.
Received on Saturday, 13 March 2010 09:46:16 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:37 GMT