fix error service deprecations
This commit is contained in:
parent
fd9d622413
commit
2998cb076f
@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { fromEvent, merge, Observable, Subject } from 'rxjs';
|
||||
import { HttpErrorResponse, HttpStatusCode } from '@angular/common/http';
|
||||
import { LoadingService } from '../loading';
|
||||
import { delay, filter, map, mapTo } from 'rxjs/operators';
|
||||
import { delay, filter, map } from 'rxjs/operators';
|
||||
import { NavigationStart, Router } from '@angular/router';
|
||||
import { shareLast } from '../utils';
|
||||
|
||||
@ -49,7 +49,10 @@ export class ErrorService {
|
||||
});
|
||||
this.offline$ = this._offline();
|
||||
this.online$ = this._online();
|
||||
const removeIndicator$ = this.online$.pipe(delay(3000), mapTo(undefined));
|
||||
const removeIndicator$ = this.online$.pipe(
|
||||
delay(3000),
|
||||
map(() => undefined),
|
||||
);
|
||||
|
||||
this.connectionStatus$ = merge(this.online$, this.offline$, removeIndicator$).pipe(map(event => event?.type));
|
||||
}
|
||||
@ -68,10 +71,17 @@ export class ErrorService {
|
||||
}
|
||||
|
||||
private _offline() {
|
||||
return merge(fromEvent(window, 'offline'), this._error$.pipe(filter(isOffline), mapTo(new Event('offline')), shareLast()));
|
||||
return merge(
|
||||
fromEvent(window, 'offline'),
|
||||
this._error$.pipe(
|
||||
filter(isOffline),
|
||||
map(() => new Event('offline')),
|
||||
shareLast(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
private _online() {
|
||||
return merge(fromEvent(window, 'online'), this._online$.pipe(mapTo(new Event('online')))).pipe(shareLast());
|
||||
return merge(fromEvent(window, 'online'), this._online$.pipe(map(() => new Event('online')))).pipe(shareLast());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user