Skip to content

Commit 6308141

Browse files
committed
Fix connect state
1 parent 83724ed commit 6308141

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/components/microbit-connect.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import { microbitStore } from '../microbit-store';
66
tag: 'microbit-connect'
77
})
88
export class MicrobitConnect {
9-
constructor() {
10-
microbitStore.addListener(this);
11-
}
12-
139
@Element() el;
1410
@Prop({mutable: true}) device: BluetoothDevice = null;
1511

@@ -38,12 +34,14 @@ export class MicrobitConnect {
3834
if (this.device.gatt.connected) {
3935
await this.device.gatt.disconnect();
4036
}
37+
this.device = null;
4138
microbitStore.empty();
4239
return;
4340
}
4441

4542
const device = await requestMicrobit(window.navigator.bluetooth);
4643
if (device) {
44+
this.device = device;
4745
microbitStore.update("device", device);
4846
const services = await getServices(device);
4947
microbitStore.update("services", services);

0 commit comments

Comments
 (0)