Closed cjdelisle closed 8 years ago
Hi there,
I do not agree there, and find the use of Promise a really good choice. You'll notice that the latest Web API features (eg https://developer.mozilla.org/fr/docs/Web/API/Fetch_API ) are using them. The JavaScript Promise implementations all respect the Promise/A+ spec (well, all but jQuery Deferred).
Here the implementation used is the ES2015 Promise object (http://www.ecma-international.org/ecma-262/6.0/#sec-promise-constructor) that is polyfilled by the transpiler (babel is used on this project) to work on ES5 navigators.
Anyway in programing everything is a matter of taste, and as so the choice of using Promise or node style callbacks is on the library developer side.
Mozilla Foundation has recently updated the WebRTC documentation. Among these updates there are a few changes about using Promises (create Offer/Answer, setRemoteDescription...). For example for the createOffer
function (https://developer.mozilla.org/enUS/docs/Web/API/RTCPeerConnection/createOffer):
Deprecated parameters
In older code and documentation, you may see a callback-based version of this function. This has been deprecated and its use is strongly discouraged. You should update any existing code to use the Promise-based version of createOffer() instead. The parameters for this form of createOffer() are described below, to aid in updating existing code.
So Promises seems to be a nice choice.
I'm concerned about the use of Promises in the
join
leave
send
andbroadcast
functions. What promise specification are you planning on using (last I was aware there were a number of different promise libraries which are incompatible). Personally I would prefer that the library did not require me to use Promises and just stuck to the nodejs-like callback with (err, ret) parameters.