- From: Anton Vayvod via GitHub <sysbot+gh@w3.org>
- Date: Thu, 03 Nov 2016 20:30:18 +0000
- To: public-secondscreen@w3.org
It is similar to ```PresentationRequest.start()``` which always
rejects if the dialog is dismissed. Otherwise if the ```state``` is
```connected```, promise returned by ```prompt()``` is useless.
```javascript
btn.onclick = function() {
if (v.remote.state === 'disconnected') {
v.remote.prompt().then(switchToRemoteState, showError);
} else {
v.remote.prompt().then(switchToLocalState);
}
};
```
The latter would be impossible if we always resolve the promise when
```connected```.
If we really want to simplify it, we could just abandon the promise
altogether and rely on the events - the website has to handle the
events anyway because the connection can be initiated by the browser
or dropped due to Wi-Fi - both without ```prompt()``` being called at
all.
--
GitHub Notification of comment by avayvod
Please view or discuss this issue at
https://github.com/w3c/remote-playback/issues/63#issuecomment-258264642
using your GitHub account
Received on Thursday, 3 November 2016 20:30:24 UTC