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

Merged
androiddrew merged 1 commits from drew/fix-disconnect-after-write into main 8 months ago

@ -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; }
};
}