From d18ce375adc1c9053fca7931d9c1358d8bda214f Mon Sep 17 00:00:00 2001 From: gdorsi Date: Tue, 12 Nov 2019 11:56:31 +0100 Subject: [PATCH] update the connection button at every connection change --- comms.js | 16 ++++++++++++++++ index.html | 2 +- index.js | 11 ++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/comms.js b/comms.js index 96857ce32..e0fd19d10 100644 --- a/comms.js +++ b/comms.js @@ -63,5 +63,21 @@ setTime : () => { resolve(); }); }); +}, +watchConnectionChange : cb => { + var connected = Puck.isConnected(); + + //TODO Switch to an event listener when Puck will support it + var interval = setInterval(() => { + if (connected === Puck.isConnected()) return; + + connected = Puck.isConnected(); + cb(connected); + }, 1000); + + //stop watching + return () => { + clearInterval(interval); + }; } }; diff --git a/index.html b/index.html index 4d6e0691d..a0a147948 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@