Browse Source

sending navigator.onLine instead of null

pull/17027/head
Sinan997 3 years ago
parent
commit
70e1927f53
  1. 8
      npm/ng-packs/packages/core/src/lib/services/internet-connection-service.ts

8
npm/ng-packs/packages/core/src/lib/services/internet-connection-service.ts

@ -1,4 +1,5 @@
import { Injectable } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { Injectable, inject } from '@angular/core';
import { fromEvent, merge, of } from 'rxjs';
import { map } from 'rxjs/operators';
@ -6,8 +7,11 @@ import { map } from 'rxjs/operators';
providedIn: 'root',
})
export class InternetConnectionService{
protected readonly window = inject(DOCUMENT).defaultView;
protected readonly navigator = this.window.navigator;
networkStatus$ = merge(
of(null),
of(navigator.onLine),
fromEvent(window, 'offline'),
fromEvent(window, 'online')
).pipe(map(() => navigator.onLine))

Loading…
Cancel
Save