On 9/14/15 5:08 PM, Martin Thomson wrote:
> On 14 September 2015 at 14:03, Harald Alvestrand <harald@alvestrand.no> wrote:
>> I don't see any huge advantage of using "dictionary" over "interface",
>> but that may be just me.
> Here's why:
>
> Previously:
>
> signaling.oncandidate = c => {
> RTCIceCandidate = RTCIceCandidate || mozRTCIceCandidate;
> pc.addIceCandidate(new RTCIceCandidate(c));
> };
>
> With the change:
>
> signaling.oncandidate = c => {
> pc.addIceCandidate(c);
> };
I agree.
Though strictly speaking, we don't need to get rid of the
RTCIceCandidate interface to accomplish this. All we'd need is:
- Promise<void> addIceCandidate (RTCIceCandidate candidate);
+ Promise<void> addIceCandidate (optional RTCIceCandidateInit
candidate);
Since the interface has a serializer, addIceCandidate will now accept
either. *
That said, I see little value in keeping a serializable interface for
its readonly properties, given how malleable it is:
pc.onicecandidate = e => {
var can = JSON.parse(JSON.stringify(e.candidate));
can. sdpMLineIndex++;
can = new RTCIceCandidate(can);
// Do something with can...
};
.: Jan-Ivar :.
*) the init-dict pattern was designed with interface-cloning in mind.