Anyway to detect specific device disconnect? #548
-
We're using ya-webadb at the company I'm working for to develop a tool for testing our app. Currently all runs well, but I can't get the UI to update when the device disconnects. WebUSB supports the ondisconnect function which passes the serialNumber through the event object. I was planning on using this to detect if the device using Adb had disconnected but the Adb object has no 'serialNumber' parameter. Is there anything I'm missing here where I can just add a listener? Using React just want to update the state. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In a previous version You need to keep the backend instance or at least the serial number somewhere else in your code, like the demo project does: ya-webadb/apps/demo/src/state/global.ts Lines 16 to 18 in 26fe783 ya-webadb/apps/demo/src/state/global.ts Lines 32 to 35 in 26fe783 Having a |
Beta Was this translation helpful? Give feedback.
In a previous version
Adb
class usesAdbBackend
instances directly to communicate with devices, so it was possible to read the serial number viaadb.backend.serial
. But nowAdb
andAdbBackend
are decoupled,Adb
only requires aReadableWriablePair
andAdbBackend
has aconnect
method to provide that, it's not possible to read the serial number fromAdb
instance.You need to keep the backend instance or at least the serial number somewhere else in your code, like the demo project does:
ya-webadb/apps/demo/src/state/global.ts
Lines 16 to 18 in 26fe783
ya-…