- From: Reilly Grant via GitHub <sysbot+gh@w3.org>
- Date: Fri, 11 Sep 2020 22:16:47 +0000
- To: public-web-bluetooth-log@w3.org
This is easy to do using async/await. Note that you also don't need to wait for `startNotifications()` to resolve before adding an event listener.
```js
characteristic1.addEventListener('characteristicvaluechanged', event => {
console.log('Got an Event from CAR 1');
});
characteristic2.addEventListener('characteristicvaluechanged', event => {
console.log('Got an Event from CAR 2');
});
try {
await characteristic1.startNotifications();
await characteristic2.startNotifications();
} catch (e) {
console.error(`Failed to enable characteristic value change notifications: ${e.message}`);
}
```
--
GitHub Notification of comment by reillyeon
Please view or discuss this issue at https://github.com/WebBluetoothCG/web-bluetooth/issues/516#issuecomment-691335517 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 11 September 2020 22:16:49 UTC