From cb032d26dee699eff22517ba63ea7827a4ca300c Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Wed, 11 Sep 2024 23:10:58 +0200 Subject: [PATCH] convert `openConnection` `retryWhen` (deprecated) to `retry` --- CHANGELOG.md | 6 ++++++ src/lib/hub-connection.ts | 11 +++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee9b9f2..7e18bab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [5.0.1](https://github.com/sketch7/signalr-client/compare/5.0.0...5.0.1) (2023-09-11) + +### Refactor + +- **hub connection:** convert `openConnection` `retryWhen` (deprecated) to `retry` + ## [5.0.0](https://github.com/sketch7/signalr-client/compare/4.1.0...5.0.0) (2023-09-08) ### Features diff --git a/src/lib/hub-connection.ts b/src/lib/hub-connection.ts index cda9a9b..67e0bb4 100644 --- a/src/lib/hub-connection.ts +++ b/src/lib/hub-connection.ts @@ -1,7 +1,7 @@ import { from, BehaviorSubject, Observable, Observer, timer, throwError, Subject } from "rxjs"; import { tap, map, filter, switchMap, skipUntil, delay, first, - retryWhen, scan, delayWhen, distinctUntilChanged, takeUntil + retryWhen, delayWhen, distinctUntilChanged, takeUntil,retry } from "rxjs/operators"; import { HubConnection as SignalRHubConnection, @@ -240,9 +240,8 @@ export class HubConnection { tap(() => this._connectionState$.next(connectingState)), switchMap(() => from(this.hubConnection.start())), // tap(x => console.warn(">>>> [openConnection] - connection established", x)), - retryWhen(errors => errors.pipe( - scan((errorCount: number) => ++errorCount, 0), - delayWhen((retryCount: number) => { + retry({ + delay: (error, retryCount) => { if (this.retry.maximumAttempts && retryCount > this.retry.maximumAttempts) { return throwError(() => new Error(errorCodes.retryLimitsReached)); } @@ -258,8 +257,8 @@ export class HubConnection { this.hubConnectionOptions$.next(this.hubConnectionOptions$.value); return timer(nextRetryMs); - }) - )), + } + }), tap(() => this.internalConnStatus$.next(InternalConnectionStatus.connected)), tap(() => this._connectionState$.next(connectedState)), takeUntil(this.untilDesiredDisconnects$()),