From 1f5835de1e55b5642a6692107c81b9e0cbdd705c Mon Sep 17 00:00:00 2001 From: "Michael J. Roberts" Date: Sun, 24 Apr 2022 20:39:42 +0100 Subject: [PATCH] chore(useBluetoothAPI): applied suggested lint fixes --- packages/core/useBluetooth/index.md | 23 ++++++++++++----------- packages/core/useBluetooth/index.ts | 3 ++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/core/useBluetooth/index.md b/packages/core/useBluetooth/index.md index 861b514e905..8721e12f974 100644 --- a/packages/core/useBluetooth/index.md +++ b/packages/core/useBluetooth/index.md @@ -19,14 +19,14 @@ N.B. This API is not available in Web Workers (not exposed via WorkerNavigator). ```ts import { useBluetooth } from '@vueuse/core' -const { +const { isSupported, isConnected, device, requestDevice, - server + server, } = useBluetooth({ - acceptAllDevices: true + acceptAllDevices: true, }) ``` @@ -49,32 +49,32 @@ Here, we use the characteristicvaluechanged event listener to handle reading bat ```ts import { pausableWatch, useBluetooth } from '@vueuse/core' -const { +const { isSupported, isConnected, device, requestDevice, - server + server, } = useBluetooth({ acceptAllDevices: true, optionalServices: [ - "battery_service" - ] + 'battery_service', + ], }) const batteryPercent = ref() const isGettingBatteryLevels = ref(false) -const getBatteryLevels = async () => { +const getBatteryLevels = async() => { isGettingBatteryLevels.value = true // Get the battery service: - const batteryService = await server.getPrimaryService("battery_service") + const batteryService = await server.getPrimaryService('battery_service') // Get the current battery level const batteryLevelCharacteristic = await batteryService.getCharacteristic( - "battery_level" + 'battery_level', ) // Listen to when characteristic value changes on `characteristicvaluechanged` event: @@ -89,7 +89,8 @@ const getBatteryLevels = async () => { } const { stop } = pausableWatch(isConnected, (newIsConnected) => { - if (!newIsConnected || !server.value || isGettingBatteryLevels.value) return + if (!newIsConnected || !server.value || isGettingBatteryLevels.value) + return // Attempt to get the battery levels of the device: getBatteryLevels() // We only want to run this on the initial connection, as we will use a event listener to handle updates: diff --git a/packages/core/useBluetooth/index.ts b/packages/core/useBluetooth/index.ts index ef6df3f0a40..b85e678e29d 100644 --- a/packages/core/useBluetooth/index.ts +++ b/packages/core/useBluetooth/index.ts @@ -63,7 +63,8 @@ export function useBluetooth(options?: UseBluetoothOptions) { async function requestDevice(): Promise { // This is the function can only be called if Bluetooth API is supported: - if (!isSupported) return + if (!isSupported) + return // Reset any errors we currently have: error.value = null