Skip to content

Commit b41b494

Browse files
Merge pull request #87 from basics/feature/cleanup
fix(operators): retry cleanup
2 parents b8d4a74 + c46cbbe commit b41b494

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

packages/operators/src/request/request.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { concatMap, from, throwError } from 'rxjs';
22

3-
import { cache as caching } from './cache';
3+
import { cache } from './cache';
44
import { resolveBlob, resolveJSON, resolveText } from './response';
5-
import { networkRetry } from './retry';
5+
import { retryWhenError } from './retry';
66

7-
export const request = ({ retry, cache } = {}) => {
7+
export const request = ({ retry, cache: cacheOptions } = {}) => {
88
return source =>
99
source.pipe(
1010
concatMap(req => {
@@ -14,8 +14,8 @@ export const request = ({ retry, cache } = {}) => {
1414
return throwError(() => new Error('Failed to fetch: resource not valid'));
1515
}
1616
}),
17-
networkRetry(retry),
18-
caching(cache)
17+
retryWhenError(retry),
18+
cache(cacheOptions)
1919
);
2020
};
2121

packages/operators/src/request/retry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { connectionObservable } from '../../../observables/src/dom/window.js';
1616

1717
const defaultTimeout = count => Math.min(60000, Math.pow(count, 2) * 1000);
1818

19-
export const networkRetry = ({ timeout = defaultTimeout, count } = {}) => {
19+
export const retryWhenError = ({ timeout = defaultTimeout, count } = {}) => {
2020
let counter = 0;
2121

2222
return source => {

packages/operators/src/request/retry.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { TestScheduler } from 'rxjs/testing';
33
import { beforeEach, describe, expect, test } from 'vitest';
44

55
import { log } from '../log';
6-
import { networkRetry } from './retry';
6+
import { retryWhenError } from './retry';
77

88
describe('request retry', () => {
99
let testScheduler;
@@ -26,7 +26,7 @@ describe('request retry', () => {
2626
// if you define a delay, you have to add the delay to the subscribe multiple times (num retries)
2727
const stream = cold('a|', { a: () => triggerVal.shift() }).pipe(
2828
map(fn => fn()),
29-
networkRetry({ timeout: () => 5 }),
29+
retryWhenError({ timeout: () => 5 }),
3030
log('marble:result')
3131
);
3232

0 commit comments

Comments
 (0)