- From: Vincent Scheib via GitHub <sysbot+gh@w3.org>
- Date: Fri, 29 May 2015 05:08:58 +0000
- To: public-web-bluetooth-log@w3.org
I'm undecided, but think for services/characteristics that I know may not be there I may still prefer to handle the scenario with rejected promises. Let's see what folks say when they try it. Here's a rework the earlier code with current spec behavior. I suppose it's not so bad.: ``` navigator.bluetooth.requestDevicerequestDevice({ filters: [ {services: [uuid1]} ] }).then(function(device) { return device.connectGATT(); }).then(function(gattServer) { return gattServer.getPrimaryService(uuid1); }).then(function(service) { if (!service) throw "service not found"; return service.getCharacteristics(uuid2); }).then(function(characteristics) { if (!characteristics[5]) throw "characteristics[5] not found"; characteristics[5]; // Ready to use it. }).catch(... oh noes, normal exception handling ...); ``` -- GitHub Notif of comment by scheib See https://github.com/WebBluetoothCG/web-bluetooth/issues/124#issuecomment-106690449
Received on Friday, 29 May 2015 05:08:59 UTC