Skip to content

Commit 32ab5e2

Browse files
committed
chore: Address comments
1 parent 2745d66 commit 32ab5e2

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

spec/operators/retry-spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('retry', () => {
8686
});
8787
});
8888

89-
it('should retry a number of times, then call error handler (with resetOnSuccess)', (done) => {
89+
it('should retry a number of times, then call error handler (with resetOnFirstValue)', (done) => {
9090
let errors = 0;
9191
const retries = 2;
9292
new Observable((observer: Observer<number>) => {
@@ -98,7 +98,7 @@ describe('retry', () => {
9898
errors += 1;
9999
throw 'bad';
100100
}),
101-
retry({ count: retries - 1, resetOnSuccess: true })
101+
retry({ count: retries - 1, resetOnFirstValue: true })
102102
)
103103
.subscribe({
104104
next() {
@@ -129,7 +129,7 @@ describe('retry', () => {
129129
return of(42);
130130
}
131131
}),
132-
retry({ count: retries - 1, resetOnSuccess: true })
132+
retry({ count: retries - 1, resetOnFirstValue: true })
133133
)
134134
.subscribe({
135135
next(x: number) {
@@ -179,7 +179,7 @@ describe('retry', () => {
179179
return of(42);
180180
}
181181
}),
182-
retry({ count: retries - 1, resetOnSuccess: false })
182+
retry({ count: retries - 1, resetOnFirstValue: false })
183183
)
184184
.subscribe({
185185
next(x: number) {

src/internal/operators/retry.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export interface RetryConfig {
2020
*/
2121
delay?: number | ((error: any, retryCount: number) => ObservableInput<any>);
2222
/**
23-
* Whether or not to reset the retry counter on success.
24-
* Defaults to false.
23+
* Whether or not to reset the retry counter when the retried subscription
24+
* emits its first value.
2525
*/
26-
resetOnSuccess?: boolean;
26+
resetOnFirstValue?: boolean;
2727
}
2828

2929
/**
@@ -67,21 +67,22 @@ export interface RetryConfig {
6767
* // "Error!: Retried 2 times then quit!"
6868
* ```
6969
*
70-
* @param {number} count - Number of retry attempts before failing.
71-
* @param {boolean} resetOnSuccess - When set to `true` every successful emission will reset the error count
70+
* @param count - Number of retry attempts before failing.
71+
* @param resetOnSuccess - When set to `true` every successful emission will reset the error count
7272
* @return A function that returns an Observable that will resubscribe to the
7373
* source stream when the source stream errors, at most `count` times.
7474
*/
7575
export function retry<T>(count?: number): MonoTypeOperatorFunction<T>;
7676

7777
/**
78-
* A more configurable means of retrying a source.
78+
* Returns an observable that mirrors the source observable unless it errors. If it errors, the source observable
79+
* will be resubscribed to (or "retried") based on the configuration passed here. See documentation
80+
* for {@link RetryConfig} for more details.
7981
*
80-
* If `delay` is provided as a `number`, after the source errors, the result will wait `delay` milliseconds,
81-
* then retry the source. If `delay` is a function, th
82-
* @param config The retry configuration
82+
* @param config - The retry configuration
8383
*/
8484
export function retry<T>(config: RetryConfig): MonoTypeOperatorFunction<T>;
85+
8586
export function retry<T>(configOrCount: number | RetryConfig = Infinity): MonoTypeOperatorFunction<T> {
8687
let config: RetryConfig;
8788
if (configOrCount && typeof configOrCount === 'object') {
@@ -91,7 +92,7 @@ export function retry<T>(configOrCount: number | RetryConfig = Infinity): MonoTy
9192
count: configOrCount,
9293
};
9394
}
94-
const { count = Infinity, delay, resetOnSuccess = false } = config;
95+
const { count = Infinity, delay, resetOnFirstValue: resetOnSuccess = false } = config;
9596

9697
return count <= 0
9798
? identity

0 commit comments

Comments
 (0)