W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2010

Re: [Bug 10400] New: [IndexedDB] IDBCursor.continue should return an IDBRequest

From: ben turner <bent.mozilla@gmail.com>
Date: Thu, 19 Aug 2010 11:22:48 -0700
Message-ID: <AANLkTintdEmBxtD+BuycvbURB5-ZPuAsJJUcSzTErJVR@mail.gmail.com>
To: public-webapps@w3.org
Sorry, I replied on the bug rather than to the list. Here's what I said:

Hm, I think the wording in the spec is bad, but I believe this bug is invalid.
The way we envisioned this for the async api is that calling continue() always
returns true (to match sync api, but it's really pointless) and the original
event listener is called again. There is no new request object. So it works
like this:

  var request = objectStore.openCursor();
  request.onsuccess = function (event) {
    var cursor = event.result;
    if (cursor) {
      // Do something...
      alert(cursor.value);
      // And again...
      cursor.continue();
    }
    else {
      // No more values...
    }
  }

This way you don't have to define multiple request objects and event listeners.

For the sync api, I think it should work very similarly:

  var cursor = objectStore.openCursor();
  if (cursor) {
    do {
      // Do something..
      alert(cursor.value);
    } while (cursor.continue());
  }
Received on Thursday, 19 August 2010 18:23:41 GMT

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