Fix disconnect again, and expose globals in window.wsc object (#16)

Pretty simple fix

fixes #14

Co-authored-by: Drew Bednar <drew@androiddrew.com>
Reviewed-on: #16
main
Drew Bednar 8 months ago
parent f381147f16
commit 165eeee8c9

@ -34,6 +34,7 @@ export function setupEventListeners() {
} else {
console.log("Disconnecting from port...")
globals.setPortConnected(false);
globals.reader.cancel();
onPortDisconnect();
}
});

@ -64,8 +64,10 @@ export function setWriter(newWriter) {
// expose some globals for debuggin in webconsole
if (typeof window !== 'undefined') {
window.wsc = {
isPortConnected,
autoscroll,
serialPorts,
get isPortConnected() { return isPortConnected; },
get autoscroll() { return autoscroll; },
get serialPorts() { return serialPorts; },
get reader() { return reader; },
get writer() { return writer; }
};
}