import { switchMap, distinctUntilChanged } from 'rxjs/operators';
import { interval, of, Observable } from 'rxjs';

export class NetworkService {
  get isOnline(): Observable<boolean> {
    return interval(10).pipe(
      switchMap(() => of(window.navigator.onLine)),
      distinctUntilChanged()
    );
  }
}