[web-bluetooth] discussion: is there possibility to change getAvailability() be sync API (#459)

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

== discussion: is there possibility to change getAvailability() be sync API ==
The current `getAvailability()` is an async API and the given example looks like this:

```js
navigator.bluetooth.getAvailability().then(isAvailable => {
  // get BLE availability by the promise value
});
navigator.bluetooth.addEventListener('availabilitychanged', e => {
  // get BLE availability by `e.value`
});
```
This looks inconsistent a bit though it's working absolutely, and a little bit weird with the `async` attribute, take a look at the type of example:

```js
navigator.bluetooth.on('availabilitychanged', e => {
  navigator.bluetooth.getAvailability().then((isAvailable) => {
    assert.equal(e.value, isAvailable); // possible to be failed unfortunately
  });
});
```

Within this inconsistent but correct behavior, that's easier to produce a buggy application. See the ["Overall Bluetooth availability"](https://webbluetoothcg.github.io/web-bluetooth/#availability) section, at 2nd algorithm block, it shows up the **UA** SHOULD hold the status in memory, and fires event when it gets changed, so the case to get it still be async might be the first-time fetch? But IMO, blocking this method is another solution to us util the user type ACCEPT or REJECT.



Please view or discuss this issue at https://github.com/WebBluetoothCG/web-bluetooth/issues/459 using your GitHub account

Received on Thursday, 24 October 2019 14:49:44 UTC