Re: [webrtc-extensions] Can we rename setSelectedCandidatePair to selectCandidatePair ? (#178)

`setSelectedCandidatePair` was proposed as a natural counterpart to [`RTCIceTransport.getSelectedCandidatePair`](https://w3c.github.io/webrtc-pc/#dom-rtcicetransport-getselectedcandidatepair).

I don't think a setter attribute is a good fit here because:
1. `setSelectedCandidatePair` does not immediately mutate the internal slot returned by `getSelectedCandidatePair`, that only happens asynchronously.
2. `setSelectedCandidatePair` performs a complex operation (ICE agent actions), something that the [Web Platform Design Principles](https://www.w3.org/TR/design-principles/) recommends against attributes from performing.

Thinking also about @henbos's suggestion in https://github.com/w3c/webrtc-extensions/pull/175#pullrequestreview-1701469462, perhaps an overall improvement, which also makes the verb more suitable, would be to change the method signature to 

```webidl
Promise<undefined> setSelectedCandidatePair(RTCIceCandidatePair candidatePair);
```

Then the sequence of operations on `setSelectedCandidatePair` is:
- Perform input & state validation
- Return a promise
- In parallel, instruct the ICE agent to change the selected candidate pair
- Upon completion, update the `SelectedCandidatePair` internal slot
- Fire the `selectedcandidatepairchange` event
- Resolve the promise

Then the application knows when the setter completes and the getter is consistent with the result. `get/setParameters` in `RTCRtpSender` have a similar structure.

The spec changes should be minimal. What do you think?

-- 
GitHub Notification of comment by sam-vi
Please view or discuss this issue at https://github.com/w3c/webrtc-extensions/issues/178#issuecomment-1785854498 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 30 October 2023 18:56:02 UTC