react-native-bluetooth-state-manager
Version:
Manage the bluetooth state of your device
15 lines (14 loc) • 490 B
JavaScript
;
import { useSyncExternalStore } from 'react';
import { BluetoothStateManager } from './BluetoothStateManager';
export const useBluetoothState = (enabled = true) => {
console.log(`useBluetoothState({ ${enabled} })`);
if (!enabled) {
return 'Unknown';
}
return useSyncExternalStore(cb => {
const remove = BluetoothStateManager.addListener(cb);
return remove;
}, () => BluetoothStateManager.getStateSync());
};
//# sourceMappingURL=useBluetoothState.js.map