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

On Thu, Aug 19, 2010 at 7:22 PM, ben turner <bent.mozilla@gmail.com> wrote:

> 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());
>  }
>

I responded on list already.  Let's continue the discussion there.

Received on Thursday, 19 August 2010 19:06:58 UTC