Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Injectable} from '@angular/core';
- import {fromEvent} from 'rxjs';
- @Injectable({providedIn: 'root'})
- export class NetworkService {
- isOnline;
- constructor() {
- this.isOnline = window.navigator.onLine;
- fromEvent(window, 'online').subscribe(e => {
- this.online = true;
- });
- fromEvent(window, 'offline').subscribe(e => {
- this.online = false;
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement