Re: Promise slides

On 10/2/14, 10:03 AM, Adam Roach wrote:
> Sorry for falling a bit behind on the issue, but I just want to make 
> sure I understand what's under discussion here. Fundamentally, this 
> looks like a proposal to delay spec publication for a change that can 
> be retrofit with a small handful of lines of code:

Things being easy cuts both ways. Saying things are easy enough to let 
consumers figure it out on their own, yet hard enough to delay the spec 
significantly, seems a precarious balance. Not sure that's possible.

> navigator.oldGum = navigator.getUserMedia ||
>                    navigator.mozGetUserMedia ||
>                    navigator.webkitGetUserMedia;
>
> navigator.getUserMedia =
> function(constraints, successCallback, errorCallback) {
>   return new Promise(function(resolve, reject){
>     try {
>       navigator.oldGum(constraints,
>         function(stream) {
>           resolve(stream);
>           if (successCallback)
>             successCallback(stream);
>         },
>         function(error) {
>           reject(error);
>           if (errorCallback)
>             errorCallback(error);
>         });
>       } catch (error) {
>         reject(error);
>         if (successCallback || errorCallback)
>           throw(error);
>       }
>   });
> };
>
>
> Is that right? Would it make more sense to publish this somewhere so 
> that users interested in promises can use them, while giving the rest 
> of the world a finalized v1 spec?

Ah, "people interested in promises" suggests that promises isn't a 
slam-dunk, that a future for non-promise APIs. Frankly, this is where 
the WebRTC group is behind the times by a year or probably several 
years. I hope to show this and that callback APIs are so broken when it 
comes to error-handling that the world is much better without them 
existing. Giant footguns is what they are.

So I don't think anyone deserves the old callback API, because it is a 
recipe for disaster, and wherever gUM goes now, WebRTC follows, and the 
WebRTC wrapper is more complicated btw. needing wrapping of all returned 
objects like RtpSender etc. We'll be stuck with the callback nonsense 
forever.

So I want to nip this in the bud and get rid of something, not add 
something, and the only time to do *that* is now unfortunately.

.: Jan-Ivar :.

[1] http://lists.w3.org/Archives/Public/public-webrtc/2014Sep/0063.html

Received on Thursday, 2 October 2014 14:38:07 UTC