Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. import {Injectable} from '@angular/core';
  2. import {fromEvent} from 'rxjs';
  3.  
  4.  
  5. @Injectable({providedIn: 'root'})
  6. export class NetworkService {
  7.  
  8. isOnline;
  9.  
  10. constructor() {
  11.  
  12. this.isOnline = window.navigator.onLine;
  13.  
  14. fromEvent(window, 'online').subscribe(e => {
  15. this.online = true;
  16. });
  17. fromEvent(window, 'offline').subscribe(e => {
  18. this.online = false;
  19. });
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement