Skip to content

Commit

Permalink
convert openConnection retryWhen (deprecated) to retry
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlautier committed Sep 11, 2024
1 parent ec2861d commit cb032d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 5 additions & 6 deletions src/lib/hub-connection.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -240,9 +240,8 @@ export class HubConnection<THub> {
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));
}
Expand All @@ -258,8 +257,8 @@ export class HubConnection<THub> {
this.hubConnectionOptions$.next(this.hubConnectionOptions$.value);

return timer(nextRetryMs);
})
)),
}
}),
tap(() => this.internalConnStatus$.next(InternalConnectionStatus.connected)),
tap(() => this._connectionState$.next(connectedState)),
takeUntil(this.untilDesiredDisconnects$()),
Expand Down

0 comments on commit cb032d2

Please sign in to comment.