angular-reachability
v0.0.22
Published
Ionic Network Reachability, it is used for `testing` network connection.
Downloads
6
Maintainers
Readme
Ionic Network Reachability
Ionic Network Reachability, it is used for testing
network connection.
Ionic Network Reachability
npm install angular-reachability --save
Usage
app.component.ts
import { IonicNetworkReachability } from 'angular-reachability';
export class AppComponent {
constructor(private reachability: IonicNetworkReachability) {}
async checkOnline() {
try {
const isOnline = await this.reachability.isReachable('url is optional');
return isOnline;
} catch(err) {
}
}
monitoringOnlineEvents(url: string) {
this.reachability.onConnect('url is optional').subscribe((value: boolean) => {
console.log('online :)');
});
}
monitoringOfflineEvents() {
this.reachability.onDisconnect().subscribe(() => {
console.log('offline :(')
});
}
}