Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/restructure #91

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/observables/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"scripts": {
"release": "npx semantic-release"
},
"imports": {
"#mocks/*": "../mocks/*"
},
"dependencies": {
"@rxjs-collection/operators": "*",
"rxjs": "7.8.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/observables/src/dom/window.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { mockOffline, mockOnline, mockReset } from '#mocks/network.js';
import { tap } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { beforeEach, test, expect, describe, afterEach } from 'vitest';

import { mockOffline, mockOnline, mockReset } from '../../../mock/network.js';
import { connectionObservable } from './window.js';

// HINT: https://betterprogramming.pub/rxjs-testing-write-unit-tests-for-observables-603af959e251
Expand Down
7 changes: 7 additions & 0 deletions packages/operators/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Project Changelog

# [@rxjs-collection/operators-v1.0.9](https://github.com/basics/rxjs-collection/compare/@rxjs-collection/operators-v1.0.8...@rxjs-collection/operators-v1.0.9) (2024-11-24)


### Bug Fixes

* **operators:** remove skips from coverage ([62652b1](https://github.com/basics/rxjs-collection/commit/62652b13635e35a348d9ae134e389a3a1f39aa59))

# [@rxjs-collection/operators-v1.0.9-beta.1](https://github.com/basics/rxjs-collection/compare/@rxjs-collection/operators-v1.0.8...@rxjs-collection/operators-v1.0.9-beta.1) (2024-11-24)


Expand Down
6 changes: 5 additions & 1 deletion packages/operators/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rxjs-collection/operators",
"version": "1.0.9-beta.1",
"version": "1.0.9",
"description": "rxjs operators",
"license": "MIT",
"contributors": [
Expand All @@ -17,6 +17,10 @@
"scripts": {
"release": "npx semantic-release"
},
"imports": {
"#observables/*": "../observables/src/*",
"#mocks/*": "../mocks/*"
},
"dependencies": {
"@rxjs-collection/observables": "*",
"ansi-colors": "4.1.3",
Expand Down
14 changes: 14 additions & 0 deletions packages/operators/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export { autoPagination } from './request/autoPagination';
export { cache } from './request/cache';
export { concurrentRequest } from './request/concurrentRequest';
export { lazyPagination } from './request/lazyPagination';
export { polling } from './request/polling';
export { request, requestJSON, requestText, requestBlob } from './request/request';
export {
resolve,
resolveJSON,
resolveText,
resolveBlob,
distinctUntilResponseChanged
} from './request/response';
export { retryWhenError } from './request/retry';
4 changes: 2 additions & 2 deletions packages/operators/src/request/autoPagination.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { mockAsync } from '#mocks/async';
import { mockResponse } from '#mocks/response';
import { concatAll, delay, from, map, of } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { afterAll, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';

import { mockAsync } from '../../../mock/async';
import { mockResponse } from '../../../mock/response';
import { log, logResult } from '../log';
import { resolveJSON } from './response';

Expand Down
4 changes: 2 additions & 2 deletions packages/operators/src/request/concurrentRequest.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { mockAsync } from '#mocks/async';
import { mockResponse } from '#mocks/response';
import { concatAll, delay, map, of } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { afterAll, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';

import { mockAsync } from '../../../mock/async';
import { mockResponse } from '../../../mock/response';
import { log, logResult } from '../log';
import { resolveJSON, resolveText } from './response';

Expand Down
4 changes: 2 additions & 2 deletions packages/operators/src/request/lazyPagination.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { mockAsync } from '#mocks/async';
import { mockResponse } from '#mocks/response';
import { concatAll, delay, map, of, Subject, tap } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { afterAll, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';

import { mockAsync } from '../../../mock/async';
import { mockResponse } from '../../../mock/response';
import { log, logResult } from '../log';
import { resolveJSON } from './response';

Expand Down
5 changes: 2 additions & 3 deletions packages/operators/src/request/polling.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { mockAsync } from '#mocks/async';
import { mockResponse } from '#mocks/response';
import { concatMap } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { afterAll, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';

import { mockAsync } from '../../../mock/async';
import { mockResponse } from '../../../mock/response';

describe('polling', () => {
let testScheduler;

Expand Down
4 changes: 2 additions & 2 deletions packages/operators/src/request/request.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { mockAsync } from '#mocks/async.js';
import { mockResponse } from '#mocks/response.js';
import { readFile } from 'node:fs/promises';
import { of } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { test, describe, beforeEach, expect, vi, afterAll, beforeAll } from 'vitest';

import { mockAsync } from '../../../mock/async.js';
import { mockResponse } from '../../../mock/response.js';
import { log, logResult } from '../log.js';
import { resolveJSON } from './response.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/operators/src/request/response.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { mockResponse } from '#mocks/response';
import { concatMap } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { afterEach, test, describe, beforeEach, expect, vi, beforeAll } from 'vitest';

import { mockResponse } from '../../../mock/response';
import { log } from '../log';
import { distinctUntilResponseChanged, resolveJSON, resolveText } from './response';

Expand Down
3 changes: 1 addition & 2 deletions packages/operators/src/request/retry.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { connectionObservable } from '#observables/dom/window.js';
import {
combineLatest,
concatMap,
Expand All @@ -12,8 +13,6 @@
throwError
} from 'rxjs';

import { connectionObservable } from '../../../observables/src/dom/window.js';

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

export const retryWhenError = ({ timeout = defaultTimeout, count } = {}) => {
Expand Down Expand Up @@ -44,7 +43,7 @@
tap(valid => (counter = counter * valid)),
// continue only if all observables are valid
filter(valid => valid),
tap(() => console.log(`retry: request - next: ${counter} in ${timeout(counter)}ms`)),

Check warning on line 46 in packages/operators/src/request/retry.js

View workflow job for this annotation

GitHub Actions / Install (ubuntu-latest, 20)

Unexpected console statement
delay(timeout(counter))
);
};
Loading