W3C home > Mailing lists > Public > public-web-bluetooth-log@w3.org > August 2016

Re: [web-bluetooth] Treat sites as not bonded to their devices.

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
Message-ID: <issue_comment.created-239389639-1470990327-sysbot+gh@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

This archive was generated by hypermail 2.3.1 : Friday, 12 August 2016 08:25:40 UTC