From 68ac5e6ec2ff4dc11bf4ce9c7ce977b0b1e7c7e6 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sat, 10 Jun 2023 16:43:20 +0200 Subject: [PATCH] fix(core): update --- test/test.both.ts | 1 + ts/00_commitinfo_data.ts | 2 +- ts/index.ts | 11 +++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test/test.both.ts b/test/test.both.ts index d3fda03..dd458c5 100644 --- a/test/test.both.ts +++ b/test/test.both.ts @@ -19,6 +19,7 @@ tap.test('should be online', async () => { testWebDetector.onlineObservable.subscribe((state) => { console.log(state); }); + testWebDetector.stopPeriodicChecks(); }); tap.test('should detect the platform', async () => { diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index db3a2ba..263a041 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@pushrocks/webdetector', - version: '2.0.1', + version: '2.0.2', description: 'detect different environments within the browser' } diff --git a/ts/index.ts b/ts/index.ts index ae79dda..fa055b0 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -53,10 +53,17 @@ export class WebDetector { return reachesInternet; } - async startPeriodicChecks() { - while (true) { + private periodicChecksRunning = false; + + public async startPeriodicChecks() { + this.periodicChecksRunning = true; + while (this.periodicChecksRunning) { await this.isOnline(); await plugins.smartdelay.delayFor(3000); } } + + public async stopPeriodicChecks() { + this.periodicChecksRunning = false; + } }