Le 06/11/2012 18:36, David Bruant a écrit :
> Both the enumerate and enumerateEditable could return ES6 generators
> [1] instead of a custom thing that mimics the exact same behavior.
> SpiderMonkey already has generators. If WedIDL has nothing to use ES
> generators, let's send feedback to get it.
For that part, it's been brought to my attention [1] that DeviceStorage
is asynchronous, so an ES6 iterator (it's the interface. generators are
an implementation of this interface and other things) isn't the right fit.
I guess I don't understand the point of the "continue". Apparently,
there is an equivalent construct in IDB. I've seen code samples and the
weird part is the .continue. Basically, the developer has to opt-in to
continue enumerate results. It goes against the habit (and what's
natural in my opinion) to continue by default and having an opt-in for
*stopping* the enumeration:
* ES5 array extras enumerate all by default (you can throw to stop),
* iterators enumerate all by default (you have to throw a specific value
to stop the iteration)
* for/for-in loops enumerate all by default and you have to "break" to
stop the iteration
Is there a specific reason to have chosen the opposite direction for
DeviceStorageCursor? Does the web dev wants to stop the enumeration by
default?
If not, an "abort" function would be more relevant than a "continue"
function.
An alternative is to return an array of DOMRequest (or promises), each
corresponding to a given "file". With ES6 proxies (or C++ magic),
everything, even the DOMRequests instances can be built lazily.
David
[1]
http://lists.w3.org/Archives/Public/public-script-coord/2012OctDec/0130.html