reactjrx 2.1.0 → 2.1.2
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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/queries/createObservableQueryFn.d.ts +8 -9
- package/dist/lib/queries/useQueries$.live.test.d.ts +1 -0
- package/dist/lib/queries/useQuery$.efficiency.test.d.ts +1 -0
- package/dist/lib/queries/useQuery$.offline.test.d.ts +1 -0
- package/dist/lib/queries/useQuery$.options.test.d.ts +1 -0
- package/dist/lib/queries/useQuery$.persist.test.d.ts +1 -0
- package/dist/tests/liveQuery.d.ts +18 -3
- package/package.json +1 -1
|
@@ -5,14 +5,13 @@ export type ObservableQueryFn<TQueryFnData = unknown, TQueryKey extends QueryKey
|
|
|
5
5
|
* Bridges an Observable-based `queryFn` to the Promise-based `queryFn`
|
|
6
6
|
* expected by TanStack Query. Shared by `useQuery$` and `useQueries$`.
|
|
7
7
|
*
|
|
8
|
-
* Every value is written into the query as soon as the stream emits it.
|
|
9
|
-
* fetch TanStack starts (mount, `refetch()`, `invalidateQueries()`...)
|
|
10
|
-
* once the stream has a value in the cache, like a
|
|
11
|
-
* it settles. Right after it, the bridge starts a
|
|
12
|
-
* stream: it keeps the query `fetching` while the
|
|
13
|
-
* the stream completes or errors.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* the stream.
|
|
8
|
+
* Every value is written into the query as soon as the stream emits it. Each
|
|
9
|
+
* fetch TanStack starts (mount, `refetch()`, `invalidateQueries()`...) runs
|
|
10
|
+
* the `queryFn` and ends once the stream has a value in the cache, like a
|
|
11
|
+
* regular query, so awaiting it settles. Right after it, the bridge starts a
|
|
12
|
+
* fetch that follows the stream: it keeps the query `fetching` while the
|
|
13
|
+
* stream runs and ends when the stream completes or errors. Cancelling the
|
|
14
|
+
* fetch in progress (a refetch replacing it, the last observer unmounting,
|
|
15
|
+
* `cancelQueries`, the query leaving the cache) stops the stream.
|
|
17
16
|
*/
|
|
18
17
|
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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
|
-
import { BehaviorSubject } from 'rxjs';
|
|
3
|
+
import { BehaviorSubject, Observable } from 'rxjs';
|
|
4
4
|
export declare function createQueryClient(): QueryClient;
|
|
5
|
+
/**
|
|
6
|
+
* Options for a live query. It keeps the default `staleTime`: automatic
|
|
7
|
+
* refetches join a running stream anyway, and a longer one would keep a
|
|
8
|
+
* stopped or restored query from reopening its stream.
|
|
9
|
+
*/
|
|
5
10
|
export declare const liveQueryOptions: {
|
|
6
11
|
networkMode: "always";
|
|
7
12
|
gcTime: number;
|
|
8
|
-
staleTime: number;
|
|
9
13
|
};
|
|
10
14
|
/**
|
|
11
15
|
* Emulates a live database query: `queryFn` emits a fresh copy of the current
|
|
@@ -13,7 +17,18 @@ export declare const liveQueryOptions: {
|
|
|
13
17
|
*/
|
|
14
18
|
export declare function createLiveQuerySource(initialItems: string[]): {
|
|
15
19
|
liveQuery$: BehaviorSubject<string[]>;
|
|
16
|
-
queryFn: () =>
|
|
20
|
+
queryFn: () => Observable<string[]>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Wraps `source` to count its subscriptions: how many were made, and how
|
|
24
|
+
* many are still open.
|
|
25
|
+
*/
|
|
26
|
+
export declare function countSubscriptions<T>(source: Observable<T>): {
|
|
27
|
+
counted$: Observable<T>;
|
|
28
|
+
subscriptions: {
|
|
29
|
+
made: number;
|
|
30
|
+
open: number;
|
|
31
|
+
};
|
|
17
32
|
};
|
|
18
33
|
export declare function createWrapper(queryClient: QueryClient): ({ children }: {
|
|
19
34
|
children: React.ReactNode;
|