Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- import { Network } from '@ionic-native/network';
- import { Subscription } from 'rxjs/Subscription';
- @Injectable()
- export class NetworkProvider {
- connect: Subscription;
- disconnect: Subscription;
- constructor(private _network: Network) { }
- watchDisconect() {
- this.disconnect = this._network.onDisconnect().subscribe(data => {
- console.log('network was disconnected :-(');
- });
- this.disconnect.unsubscribe();
- }
- watchConect() {
- this.connect = this._network.onConnect().subscribe(data => {
- console.log('network connected!');
- setTimeout(() => {
- if (this._network.type === 'wifi') {
- console.log('we got a wifi connection, woohoo!');
- }
- }, 3000);
- });
- this.connect.unsubscribe();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement