[IndexedDB] IDBCursor.continue should return an IDBRequest

Moving to on-list since this is more of a discussion...

On Thu, Aug 19, 2010 at 6:36 PM, <bugzilla@jessica.w3.org> wrote:

> http://www.w3.org/Bugs/Public/show_bug.cgi?id=10400
>
>
> Ben Turner <bent.mozilla@gmail.com> changed:
>
>           What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>                 CC|                            |bent.mozilla@gmail.com
>
>
>
>
> --- Comment #1 from Ben Turner <bent.mozilla@gmail.com>  2010-08-19
> 17:36:28 ---
> (In reply to comment #0)
>
> 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,


We shouldn't return a meaningless value.  The sync API functions return a
lot of stuff because they operate synchronously.  Returning true is going to
confuse people.


> 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.
>

I guess that makes sense.  I wonder whether .continue() should return an
IDBRequest (even if it's the same object as what was returned by
.openCursor), but at the same time I could see that being a bit confusing to
users.  So I think having it return nothing (not true) is what we should be
doing here.

One last question, in your example, what would "event.source" return?  Would
it always be "objectStore"?  That seems a bit weird, but having it change
between the first and subsequent calls + having event.request ==
event.source seems worse.


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

Agreed.

Received on Thursday, 19 August 2010 21:31:16 UTC