Re: Promises in 1.0

I've develop a function that set a Node.js callback on a Promise,
maybe they would implement internally something similar (Promises
first, callbacks as alternative):

https://github.com/piranna/promisecallback

2015-04-07 14:20 GMT+02:00 Iñaki Baz Castillo <ibc@aliax.net>:
> Hi,
>
> I don't fully understand why the whole API has moved from callbacks to
> promises just when 1.0 seems close to frozen. Anyhow ok, it's done.
>
> However, how could the JS detect whether the underlying WebRTC stack
> in the browser supports callbacks and/or promises?
>
> I mean: I'm pretty sure browsers will accepts callbacks for a while
> (by inspecting the number of params given to, for example,
> createOffer) but what about if the JS really *wants* to use promises
> when available? how to know *when* they are available?
>
>
> For example, one may suggest something like this:
>
> var p = navigator.getUserMedia(c,s,e);
> if (p && p.then) {
>   p.then(s).catch(e);
> }
>
>
> ...and may be s or e are called twice, depending on how the browser
> internally implements the backwards-compatibility stuff.
>
> Any reliable way for this?
>
>
> --
> Iñaki Baz Castillo
> <ibc@aliax.net>
>



-- 
"Si quieres viajar alrededor del mundo y ser invitado a hablar en un
monton de sitios diferentes, simplemente escribe un sistema operativo
Unix."
– Linus Tordvals, creador del sistema operativo Linux

Received on Tuesday, 7 April 2015 12:31:35 UTC