[web-bluetooth] Set up `characteristicvaluechanged` event handlers if `startNotifications` fulfills its promise

beaufortfrancois has just created a new issue for 
https://github.com/WebBluetoothCG/web-bluetooth:

== Set up `characteristicvaluechanged` event handlers if 
`startNotifications` fulfills its promise ==
It may be better to set up `characteristicvaluechanged` event handlers
 only if `startNotifications` fulfills its promise.

This means example at 
http://webbluetoothcg.github.io/web-bluetooth/#example-a130a116 should
 be

```js
function handleHeartRateMeasurementCharacteristic(characteristic) {
  return characteristic.startNotifications()
  .then(() => {
    characteristic.addEventListener('characteristicvaluechanged', 
onHeartRateChanged);
  });
}
```

instead of 

```js
function handleHeartRateMeasurementCharacteristic(characteristic) {
  characteristic.addEventListener('characteristicvaluechanged', 
onHeartRateChanged);
  return characteristic.startNotifications();
}
```

It would be great as well to return the characteristic in the 
fulfilled promise instead of `undefined`.

See https://github.com/WebBluetoothCG/web-bluetooth/issues/176

Received on Friday, 16 October 2015 08:39:31 UTC