reactjrx 1.142.2 → 1.142.4
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/QueryClientProvider$.d.ts +8 -3
- package/dist/lib/queries/QueryClientProvider$.liveQuery.test.d.ts +1 -0
- package/dist/lib/state/persistence/helpers.d.ts +6 -1
- package/dist/lib/state/persistence/persistSignals.d.ts +6 -1
- package/dist/lib/state/react/usePersistSignals.d.ts +8 -2
- package/dist/tests/liveQuery.d.ts +9 -0
- package/package.json +1 -1
|
@@ -12,11 +12,16 @@ type CacheEntry = {
|
|
|
12
12
|
};
|
|
13
13
|
export declare class QueryClient$ {
|
|
14
14
|
readonly queryClient: QueryClient;
|
|
15
|
-
|
|
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>;
|
|
16
21
|
constructor(queryClient: QueryClient);
|
|
17
|
-
getQuery(
|
|
22
|
+
getQuery(queryKey: QueryKey): CacheEntry | undefined;
|
|
18
23
|
setQuery(queryKey: QueryKey, query$: Observable<unknown>, signal: AbortSignal): CacheEntry;
|
|
19
|
-
deleteQuery(
|
|
24
|
+
deleteQuery(queryKey: QueryKey, { cancelQuery }?: {
|
|
20
25
|
cancelQuery?: boolean;
|
|
21
26
|
}): void;
|
|
22
27
|
destroy(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,7 +4,12 @@ export declare const persistValue: ({ adapter, config, }: {
|
|
|
4
4
|
adapter: Adapter;
|
|
5
5
|
config: SignalPersistenceConfig<any>;
|
|
6
6
|
}) => import('rxjs').Observable<unknown>;
|
|
7
|
-
export declare function hydrateValueToSignal({ adapter, config, }: {
|
|
7
|
+
export declare function hydrateValueToSignal({ adapter, config, resetToDefault, }: {
|
|
8
8
|
adapter: Adapter;
|
|
9
9
|
config: SignalPersistenceConfig<any>;
|
|
10
|
+
/**
|
|
11
|
+
* When nothing usable is stored, reset the signal to its default instead of
|
|
12
|
+
* leaving its current value in place.
|
|
13
|
+
*/
|
|
14
|
+
resetToDefault?: boolean;
|
|
10
15
|
}): import('rxjs').Observable<unknown>;
|
|
@@ -17,13 +17,18 @@ type Entry = SignalPersistenceConfig<AnySignal>;
|
|
|
17
17
|
* hydrate is logged and never persisted, and holds back that emission until
|
|
18
18
|
* it is removed.
|
|
19
19
|
*/
|
|
20
|
-
export declare function persistSignals({ entries$, onHydrated, adapter, }: {
|
|
20
|
+
export declare function persistSignals({ entries$, onHydrated, adapter, resetToDefault, }: {
|
|
21
21
|
entries$: Observable<Entry[]>;
|
|
22
22
|
/**
|
|
23
23
|
* Called when `{ type: "hydrated" }` is emitted.
|
|
24
24
|
*/
|
|
25
25
|
onHydrated?: () => void;
|
|
26
26
|
adapter: Adapter;
|
|
27
|
+
/**
|
|
28
|
+
* When true, an entry with nothing usable stored goes back to its default
|
|
29
|
+
* instead of keeping its current value.
|
|
30
|
+
*/
|
|
31
|
+
resetToDefault?: boolean;
|
|
27
32
|
}): Observable<{
|
|
28
33
|
type: "hydrated";
|
|
29
34
|
}>;
|
|
@@ -22,8 +22,14 @@ export declare function usePersistSignals({ entries, onHydrated, adapter, }: {
|
|
|
22
22
|
onHydrated?: () => void;
|
|
23
23
|
/**
|
|
24
24
|
* Passing a new adapter reference starts over: pending values are saved to
|
|
25
|
-
* the previous adapter, then every entry
|
|
26
|
-
*
|
|
25
|
+
* the previous adapter, then every entry takes the value stored in the new
|
|
26
|
+
* one. When nothing is stored, or only an older version, the entry goes
|
|
27
|
+
* back to its default once the hook has had two different adapters, so it
|
|
28
|
+
* never carries another adapter's value over (another profile's, for
|
|
29
|
+
* example). Before that, including when the same adapter comes back after
|
|
30
|
+
* a gap without adapter, it keeps its current value. Adapters are compared
|
|
31
|
+
* by reference: a new object for the same storage counts as a different
|
|
32
|
+
* adapter. Use a stable reference to avoid infinite loop.
|
|
27
33
|
*/
|
|
28
34
|
adapter?: Adapter;
|
|
29
35
|
}): {
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
|
+
import { BehaviorSubject } from 'rxjs';
|
|
3
4
|
export declare function createQueryClient(): QueryClient;
|
|
4
5
|
export declare const liveQueryOptions: {
|
|
5
6
|
networkMode: "always";
|
|
6
7
|
gcTime: number;
|
|
7
8
|
staleTime: number;
|
|
8
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Emulates a live database query: `queryFn` emits a fresh copy of the current
|
|
12
|
+
* items whenever `liveQuery$` pushes a new list.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createLiveQuerySource(initialItems: string[]): {
|
|
15
|
+
liveQuery$: BehaviorSubject<string[]>;
|
|
16
|
+
queryFn: () => import('rxjs').Observable<string[]>;
|
|
17
|
+
};
|
|
9
18
|
export declare function createWrapper(queryClient: QueryClient): ({ children }: {
|
|
10
19
|
children: React.ReactNode;
|
|
11
20
|
}) => import("react/jsx-runtime").JSX.Element;
|