mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
28 lines
554 B
TypeScript
28 lines
554 B
TypeScript
|
|
import { Injectable } from '@angular/core';
|
||
|
|
import { BehaviorSubject, Observable } from 'rxjs'
|
||
|
|
import { Platform } from '@ionic/angular'
|
||
|
|
|
||
|
|
@Injectable({
|
||
|
|
providedIn: 'root'
|
||
|
|
})
|
||
|
|
|
||
|
|
export class NetworkConnectionService {
|
||
|
|
online: boolean = true;
|
||
|
|
|
||
|
|
constructor(){}
|
||
|
|
|
||
|
|
checkOnline() {
|
||
|
|
window.addEventListener('online', (on) => {
|
||
|
|
this.online === true;
|
||
|
|
console.log('Became online');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
checkOffline() {
|
||
|
|
window.addEventListener('offline', (off) => {
|
||
|
|
this.online === false;
|
||
|
|
console.log('Became offline')
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|