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

Re: [web-bluetooth] Consider devicechange event for when a new granted bluetooth device is made available,

From: François Beaufort via GitHub <sysbot+gh@w3.org>
Date: Fri, 05 Aug 2016 07:05:26 +0000
To: public-web-bluetooth-log@w3.org
Message-ID: <issue_comment.created-237772455-1470380724-sysbot+gh@w3.org>
For the sake of completeness, is this how it would work?

```js
navigator.permissions.query({
  name: "bluetooth",
  deviceId: sessionStorage.lastDevice /* because we've stored it 
previously */
}).then(result => {
  result.addEventListener('change', function(event) {
    // Permission status has changed for this device
    console.log(event.target);
  })
})
```

If `result.devices` were to return multiple devices, would there be 
multiple events fired for each device?

Is this how do I access a newly paired `BluetoothDevice` object with 
this `change`  triggered event?
```js
navigator.permissions.query({
  name: "bluetooth",
  optionalServices: [ 'battery_service' ], 
}).then(result => {
  result.addEventListener('change', function(event) {
    console.log(event.target); /* Is this BluetoothDevice?
  })
})
```

@jyasskin Sorry for this, I'm still having hard time getting the full 
`Permissions` API scope for Web Bluetooth. 

-- 
GitHub Notification of comment by beaufortfrancois
Please view or discuss this issue at 
https://github.com/WebBluetoothCG/web-bluetooth/issues/257#issuecomment-237772455
 using your GitHub account
Received on Friday, 5 August 2016 07:07:30 UTC

This archive was generated by hypermail 2.3.1 : Friday, 5 August 2016 07:07:31 UTC