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