On Mon, May 14, 2012 at 2:03 PM, Anant Narayanan <[email protected]> wrote: >> - Use events or callbacks (or DOMRequests) for asynchronous calls. >> getUserMedia() will probably use callbacks so it may be more consistent >> to also use callbacks here. > > I'd prefer callbacks, not only because it's consistent with getUserMedia, > but also that DOMRequests seem more suited to objects that are actually in > the DOM tree (and need to take advantage of multiple listeners, event > bubbling, etc). These are not applicable to Media Streams.
I'm not sure where you got the impression that DOMRequest is best suited for the DOM tree. We currently don't use them anywhere where we have DOM trees. Likewise, IDBRequest (which basically is a superclass of DOMRequest) is used all over IndexedDB which isn't connected to DOM trees. Similarly XMLHttpRequest and FileReader both use events without using DOM trees. Ideally I would like to use promises, but unfortunately there's no standard for those yet. The problem that I have with callbacks is they aren't very easy to expand. For example the geolocation API uses a callback to let the page know about the user's current location. However if you look at many mapping applications they show an approximate user location which is gradually refined until a precise location is known. In order to add this ability to the geolocation API we'd need to add a third function argument (of which two would be optional) which makes the signature pretty messy. Likewise, it's hard to add the ability to cancel a asynchronous request when using the callback style. We had the same problem when designing the FileReader API. I initially proposed using callbacks, but a big reason we switched to using events was because providing progress notifications and the ability to abort a started load was hard otherwise. >> - Expose each control as a property or provide a generic >> setFeature()/getFeature() access? > > Individual properties are better than generic methods, IMHO. Otherwise we > run the risk of overloading too many things into a single function, like > ioctl. I agree. / Jonas _______________________________________________ dev-media mailing list [email protected] https://lists.mozilla.org/listinfo/dev-media

