Skip to content

Commit 4d264de

Browse files
Merge pull request #86 from basics/feature/optimization
Feature/optimization
2 parents 271e580 + e1a0d3e commit 4d264de

File tree

6 files changed

+15
-6
lines changed

6 files changed

+15
-6
lines changed

packages/operators/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Project Changelog
22

3+
# [@rxjs-collection/operators-v1.0.7](https://github.com/basics/rxjs-collection/compare/@rxjs-collection/operators-v1.0.6...@rxjs-collection/operators-v1.0.7) (2024-11-24)
4+
5+
6+
### Bug Fixes
7+
8+
* **operators:** cleanup ([daec245](https://github.com/basics/rxjs-collection/commit/daec245ffb1f6c5ea9001a47cb84a26717c45502))
9+
310
# [@rxjs-collection/operators-v1.0.7-beta.1](https://github.com/basics/rxjs-collection/compare/@rxjs-collection/operators-v1.0.6...@rxjs-collection/operators-v1.0.7-beta.1) (2024-11-24)
411

512

packages/operators/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rxjs-collection/operators",
3-
"version": "1.0.7-beta.1",
3+
"version": "1.0.7",
44
"description": "rxjs operators",
55
"license": "MIT",
66
"contributors": [

packages/operators/src/request/cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ReplaySubject, share, timer } from 'rxjs';
22

3-
export const cache = ttl => {
3+
export const cache = ({ ttl = 0 } = {}) => {
44
return source =>
55
source.pipe(
66
share({

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('cache', () => {
2222
testScheduler.run(({ cold, expectObservable }) => {
2323
const stream = cold('a', { a: () => triggerVal.shift() }).pipe(
2424
map(fn => fn()),
25-
cache(2)
25+
cache({ ttl: 2 })
2626
);
2727

2828
const unsubA = '-^!';

packages/operators/src/request/request.js

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

3+
import { cache as caching } from './cache';
34
import { resolveBlob, resolveJSON, resolveText } from './response';
45
import { networkRetry } from './retry';
56

6-
export const request = options => {
7+
export const request = ({ retry, cache } = {}) => {
78
return source =>
89
source.pipe(
910
concatMap(req => {
@@ -13,7 +14,8 @@ export const request = options => {
1314
return throwError(() => new Error('Failed to fetch: resource not valid'));
1415
}
1516
}),
16-
networkRetry(options)
17+
networkRetry(retry),
18+
caching(cache)
1719
);
1820
};
1921

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('request', () => {
6767

6868
testScheduler.run(({ cold, expectObservable }) => {
6969
const stream = cold('a|', { a: () => triggerVal.shift()() }).pipe(
70-
request({ timeout: () => 5 })
70+
request({ retry: { timeout: () => 5 } })
7171
);
7272
expectObservable(stream).toBe('----------c|', expectedVal);
7373
});

0 commit comments

Comments
 (0)