refactor to global static variables to store application states.
This commit is contained in:
@@ -23,6 +23,7 @@ type PeripheralItem = {
|
||||
isConnected: boolean;
|
||||
rssi: number | null;
|
||||
battery: number | null;
|
||||
services: { uuid: string; characteristics: string[] }[];
|
||||
};
|
||||
type BluetoothState = {
|
||||
ready: boolean | null;
|
||||
@@ -84,7 +85,6 @@ export const AvailablePeripherals = atom((get) => {
|
||||
});
|
||||
export const UnknownPeripherals = atom((get) => {
|
||||
const peripherals = get(Peripherals);
|
||||
console.debug('[origin peripherals]', peripherals);
|
||||
return peripherals.filter((i) => i.isUnknown);
|
||||
});
|
||||
const Channels: Record<Channels, PrimitiveAtom<ChannelState>> = {
|
||||
@@ -158,7 +158,7 @@ const EstimWatchProvider: FC<{ children?: ReactNode }> = ({ children }) => {
|
||||
try {
|
||||
unlistenBle.current = await listen('central_state_updated', () => refreshBle());
|
||||
unlistenDevice.current = await listen('peripheral_connected', () => refreshDevice());
|
||||
unlistenPreipherals.current = await listen('peripheral_found', (event) => {
|
||||
unlistenPreipherals.current = await listen('peripheral_updated', (event) => {
|
||||
refreshPeripherals(event.payload);
|
||||
});
|
||||
unlistenChannelA.current = await listen('channel_a_updated', () => refreshChannelA());
|
||||
|
||||
Reference in New Issue
Block a user