{"action":"opened","issue":{"url":"https://api.github.com/repos/WebBluetoothCG/web-bluetooth/issues/176","labels_url":"https://api.github.com/repos/WebBluetoothCG/web-bluetooth/issues/176/labels{/name}","comments_url":"https://api.github.com/repos/WebBluetoothCG/web-bluetooth/issues/176/comments","events_url":"https://api.github.com/repos/WebBluetoothCG/web-bluetooth/issues/176/events","html_url":"https://github.com/WebBluetoothCG/web-bluetooth/issues/176","id":111787562,"number":176,"title":"Set up `characteristicvaluechanged` event handlers if `startNotifications` fulfills its promise","user":{"login":"beaufortfrancois","id":634478,"avatar_url":"https://avatars.githubusercontent.com/u/634478?v=3","gravatar_id":"","url":"https://api.github.com/users/beaufortfrancois","html_url":"https://github.com/beaufortfrancois","followers_url":"https://api.github.com/users/beaufortfrancois/followers","following_url":"https://api.github.com/users/beaufortfrancois/following{/other_user}","gists_url":"https://api.github.com/users/beaufortfrancois/gists{/gist_id}","starred_url":"https://api.github.com/users/beaufortfrancois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beaufortfrancois/subscriptions","organizations_url":"https://api.github.com/users/beaufortfrancois/orgs","repos_url":"https://api.github.com/users/beaufortfrancois/repos","events_url":"https://api.github.com/users/beaufortfrancois/events{/privacy}","received_events_url":"https://api.github.com/users/beaufortfrancois/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-16T08:39:23Z","updated_at":"2015-10-16T08:39:23Z","closed_at":null,"body":"It may be better to set up `characteristicvaluechanged` event handlers only if `startNotifications` fulfills its promise.\r\n\r\nThis means example at http://webbluetoothcg.github.io/web-bluetooth/#example-a130a116 should be\r\n\r\n```js\r\nfunction handleHeartRateMeasurementCharacteristic(characteristic) {\r\n  return characteristic.startNotifications()\r\n  .then(() => {\r\n    characteristic.addEventListener('characteristicvaluechanged', onHeartRateChanged);\r\n  });\r\n}\r\n```\r\n\r\ninstead of \r\n\r\n```js\r\nfunction handleHeartRateMeasurementCharacteristic(characteristic) {\r\n  characteristic.addEventListener('characteristicvaluechanged', onHeartRateChanged);\r\n  return characteristic.startNotifications();\r\n}\r\n```\r\n\r\nIt would be great as well to return the characteristic in the fulfilled promise instead of `undefined`."}}