From 165eeee8c9cfbe0576ef9579102a77d9c279e60c Mon Sep 17 00:00:00 2001 From: Drew Bednar Date: Wed, 14 Aug 2024 20:27:35 +0000 Subject: [PATCH] Fix disconnect again, and expose globals in window.wsc object (#16) Pretty simple fix fixes #14 Co-authored-by: Drew Bednar Reviewed-on: https://git.runcible.io/androiddrew/webserial/pulls/16 --- src/eventListeners.js | 1 + src/globals.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/eventListeners.js b/src/eventListeners.js index a7ca9a5..9667a0d 100644 --- a/src/eventListeners.js +++ b/src/eventListeners.js @@ -34,6 +34,7 @@ export function setupEventListeners() { } else { console.log("Disconnecting from port...") globals.setPortConnected(false); + globals.reader.cancel(); onPortDisconnect(); } }); diff --git a/src/globals.js b/src/globals.js index f2c686d..3075afc 100644 --- a/src/globals.js +++ b/src/globals.js @@ -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; } }; } \ No newline at end of file