feat: connection timeout

This commit is contained in:
Thea Schöbl
2023-07-31 11:59:48 +00:00
committed by Rainer Killinger
parent 945ae039eb
commit cbc59795b7

View File

@@ -12,7 +12,18 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import {fromEvent, merge, ObservableInput, of, race, RetryConfig, share, Subject, takeUntil} from 'rxjs'; import {
delay,
fromEvent,
merge,
ObservableInput,
of,
race,
RetryConfig,
share,
Subject,
takeUntil,
} from 'rxjs';
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {filter, map, startWith, take, tap} from 'rxjs/operators'; import {filter, map, startWith, take, tap} from 'rxjs/operators';
import {NGXLogger} from 'ngx-logger'; import {NGXLogger} from 'ngx-logger';
@@ -43,6 +54,7 @@ export class InternetConnectionService {
* registering itself. * registering itself.
*/ */
readonly retryConfig: RetryConfig = { readonly retryConfig: RetryConfig = {
count: 5,
delay: this.doRetry.bind(this), delay: this.doRetry.bind(this),
}; };
@@ -52,6 +64,7 @@ export class InternetConnectionService {
tap(it => console.log(it)), tap(it => console.log(it)),
filter(it => !it), filter(it => !it),
take(1), take(1),
delay(Math.min(retryCount ** 4 + 100, 10_000)),
), ),
this.manualRetry$, this.manualRetry$,
).pipe( ).pipe(