- From: François Beaufort via GitHub <sysbot+gh@w3.org>
- Date: Fri, 12 Aug 2016 08:25:29 +0000
- To: public-web-bluetooth-log@w3.org
Does invalidating attributes when a device disconnects means attribute
becomes `null`? If so, it makes it harder to use a pattern like the
one below:
```js
var characteristic
function doSomething() {
if (!characteristic) {
return navigator.bluetooth.requestDevice({
filters: [{
services: ['battery_service']
}]
})
.then(device => device.gatt.connect())
.then(server => server.getPrimaryService('battery_service'))
.then(service => service.getCharacteristic('battery_level'))
.then(char => {
characteristic = char;
});
}
return Promise.resolve()
.then(_ => {
if (!characteristic.service.device.gatt.connected) {
// Device is not connected anymore, let's reconnect.
return characteristic.service.device.gatt.connect();
}
})
.then(_ => characteristic.readValue());
}
--
GitHub Notification of comment by beaufortfrancois
Please view or discuss this issue at
https://github.com/WebBluetoothCG/web-bluetooth/pull/273#issuecomment-239389639
using your GitHub account
Received on Friday, 12 August 2016 08:25:39 UTC