fix(core): update

This commit is contained in:
Philipp Kunz 2023-06-10 16:43:20 +02:00
parent d4401172e6
commit 68ac5e6ec2
3 changed files with 11 additions and 3 deletions

View File

@ -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 () => {

View File

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

View File

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