reactjrx 1.143.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,18 @@
1
- import { QueryClient, QueryFunctionContext, QueryKey, skipToken } from '@tanstack/react-query';
1
+ import { QueryFunctionContext, QueryKey, skipToken } from '@tanstack/react-query';
2
2
  import { Observable } from 'rxjs';
3
- import { QueryClient$ } from './QueryClientProvider$';
4
3
  export type ObservableQueryFn<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey> = ((context: QueryFunctionContext<TQueryKey>) => Observable<TQueryFnData>) | typeof skipToken | Observable<TQueryFnData>;
5
4
  /**
6
5
  * Bridges an Observable-based `queryFn` to the Promise-based `queryFn`
7
- * expected by TanStack Query. Shared by `useQuery$` and `useQueries$` so
8
- * both rely on the exact same subscription, caching and cancellation logic.
6
+ * expected by TanStack Query. Shared by `useQuery$` and `useQueries$`.
7
+ *
8
+ * Every value is written into the query as soon as the stream emits it. A
9
+ * fetch TanStack starts (mount, `refetch()`, `invalidateQueries()`...) ends
10
+ * once the stream has a value in the cache, like a regular query, so awaiting
11
+ * it settles. Right after it, the bridge starts a fetch that follows the
12
+ * stream: it keeps the query `fetching` while the stream runs and ends when
13
+ * the stream completes or errors. A refetch takes over a running stream and
14
+ * settles with its current value. Cancelling the fetch in progress (the last
15
+ * observer unmounting, `cancelQueries`, the query leaving the cache) stops
16
+ * the stream.
9
17
  */
10
- export declare function createObservableQueryFn<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey>(queryClient$: QueryClient$, queryClient: QueryClient | undefined, queryFn: ObservableQueryFn<TQueryFnData, TQueryKey> | undefined): typeof skipToken | ((context: QueryFunctionContext<TQueryKey>) => Promise<TQueryFnData>) | undefined;
18
+ export declare function createObservableQueryFn<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey>(queryFn: ObservableQueryFn<TQueryFnData, TQueryKey> | undefined): typeof skipToken | ((context: QueryFunctionContext<TQueryKey>) => Promise<TQueryFnData>) | undefined;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reactjrx",
3
3
  "private": false,
4
- "version": "1.143.0",
4
+ "version": "2.0.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -33,7 +33,7 @@
33
33
  "format": "npx @biomejs/biome check . --write"
34
34
  },
35
35
  "peerDependencies": {
36
- "@tanstack/react-query": "5.x",
36
+ "@tanstack/react-query": "^5.85.1",
37
37
  "react": "19.x",
38
38
  "react-dom": "19.x",
39
39
  "rxjs": "*"
@@ -44,7 +44,7 @@
44
44
  "@tanstack/react-query-persist-client": "^5.96.2",
45
45
  "@testing-library/jest-dom": "^7.0.0",
46
46
  "@testing-library/react": "^16.1.0",
47
- "@types/node": "^25.9.5",
47
+ "@types/node": "^26.6.5",
48
48
  "@types/react": "^19.0.2",
49
49
  "@types/react-dom": "^19.0.2",
50
50
  "@vitejs/plugin-react": "^6.0.4",
@@ -60,7 +60,7 @@
60
60
  "typescript": "^6.0.2",
61
61
  "vite": "^8.1.5",
62
62
  "vite-plugin-dts": "^5.0.1",
63
- "vitest": "^4.1.10"
63
+ "vitest": "^5.0.5"
64
64
  },
65
65
  "repository": {
66
66
  "type": "git",
@@ -1,41 +0,0 @@
1
- import { QueryClient, QueryKey } from '@tanstack/react-query';
2
- import { Observable, Subscription } from 'rxjs';
3
- type CacheEntry = {
4
- queryKey: QueryKey;
5
- query$: Observable<unknown>;
6
- signal: AbortSignal;
7
- sub: Subscription | undefined;
8
- isCompleted: boolean;
9
- lastData: {
10
- value: unknown;
11
- } | undefined;
12
- };
13
- export declare class QueryClient$ {
14
- readonly queryClient: QueryClient;
15
- /**
16
- * Keyed by the query's own `queryKey` array: the one TanStack passes to
17
- * `queryFn` and exposes as `query.queryKey`. Entries therefore match their
18
- * query whatever its `queryKeyHashFn`, and nothing is hashed.
19
- */
20
- readonly queryMap: Map<QueryKey, CacheEntry>;
21
- constructor(queryClient: QueryClient);
22
- getQuery(queryKey: QueryKey): CacheEntry | undefined;
23
- setQuery(queryKey: QueryKey, query$: Observable<unknown>, signal: AbortSignal): CacheEntry;
24
- deleteQuery(queryKey: QueryKey, { cancelQuery }?: {
25
- cancelQuery?: boolean;
26
- }): void;
27
- destroy(): void;
28
- }
29
- export declare const Context: import('react').Context<QueryClient$ | undefined>;
30
- /**
31
- * Must render **inside** TanStack `QueryClientProvider` (or equivalent).
32
- * Subscribes to that client's query cache so when a query is removed
33
- * (including via `queryClient.clear()`), matching `useQuery$` observable
34
- * entries are dropped.
35
- */
36
- export declare const QueryClientProvider$: import('react').MemoExoticComponent<({ children, client: _client, }: {
37
- children: React.ReactNode;
38
- client?: QueryClient$;
39
- }) => import('react').JSX.Element>;
40
- export declare const useQueryClient$: () => QueryClient$;
41
- export {};