reactjrx 1.142.1 → 1.142.3
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/binding/useLiveBehaviorSubject.test.d.ts +1 -0
- 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/persistSignals.d.ts +21 -11
- package/dist/lib/state/react/usePersistSignals.d.ts +13 -11
- package/dist/lib/state/react/usePersistSignals.test.d.ts +1 -0
- package/dist/lib/utils/operators/retryBackoff.d.ts +3 -4
- package/dist/tests/liveQuery.d.ts +9 -0
- package/dist/tests/teardown.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 {};
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
1
2
|
import { Signal } from '../Signal';
|
|
2
3
|
import { Adapter } from './adapters/Adapter';
|
|
3
4
|
import { SignalPersistenceConfig } from './types';
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
type AnySignal = Signal<any, string>;
|
|
6
|
+
type Entry = SignalPersistenceConfig<AnySignal>;
|
|
7
|
+
/**
|
|
8
|
+
* Hydrates the signals of the latest `entries$` list from the adapter, then
|
|
9
|
+
* persists their updates to it. Entries are matched by signal, so a new array
|
|
10
|
+
* holding the same signals changes nothing:
|
|
11
|
+
* - an added signal is hydrated, then persisted;
|
|
12
|
+
* - a signal still in the list keeps running untouched;
|
|
13
|
+
* - a removed signal stops being persisted, after its pending value is saved.
|
|
14
|
+
*
|
|
15
|
+
* Emits `{ type: "hydrated" }` once, the first time every entry added so far
|
|
16
|
+
* has been hydrated (right away for an empty list). An entry that fails to
|
|
17
|
+
* hydrate is logged and never persisted, and holds back that emission until
|
|
18
|
+
* it is removed.
|
|
19
|
+
*/
|
|
20
|
+
export declare function persistSignals({ entries$, onHydrated, adapter, }: {
|
|
21
|
+
entries$: Observable<Entry[]>;
|
|
6
22
|
/**
|
|
7
|
-
*
|
|
23
|
+
* Called when `{ type: "hydrated" }` is emitted.
|
|
8
24
|
*/
|
|
9
25
|
onHydrated?: () => void;
|
|
10
|
-
/**
|
|
11
|
-
* Requires a stable instance otherwise the hydration
|
|
12
|
-
* process will start again. This is useful when you
|
|
13
|
-
* need to change adapter during runtime.
|
|
14
|
-
*/
|
|
15
26
|
adapter: Adapter;
|
|
16
|
-
}):
|
|
27
|
+
}): Observable<{
|
|
17
28
|
type: "hydrated";
|
|
18
|
-
} | {
|
|
19
|
-
type: "persisted";
|
|
20
29
|
}>;
|
|
30
|
+
export {};
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { Adapter } from '../persistence/adapters/Adapter';
|
|
2
2
|
import { SignalPersistenceConfig } from '../persistence/types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Hydrates the signals of `entries` from `adapter`, then persists their
|
|
5
|
+
* updates to it.
|
|
6
6
|
*
|
|
7
|
-
* `isHydrated`
|
|
8
|
-
*
|
|
7
|
+
* `isHydrated` becomes `true` once the entries have been hydrated for the
|
|
8
|
+
* first time. Entries added later do not change it. It is reset when the
|
|
9
|
+
* adapter changes.
|
|
9
10
|
*/
|
|
10
11
|
export declare function usePersistSignals({ entries, onHydrated, adapter, }: {
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* Entries are matched by signal, so the array does not need a stable
|
|
14
|
+
* reference. A signal is hydrated when it is added, then persisted while it
|
|
15
|
+
* stays in the list. When it is removed, its pending value is saved and it
|
|
16
|
+
* stops being persisted.
|
|
15
17
|
*/
|
|
16
18
|
entries?: Array<SignalPersistenceConfig<any>>;
|
|
17
19
|
/**
|
|
18
|
-
*
|
|
20
|
+
* Called once per adapter, when `isHydrated` becomes `true`.
|
|
19
21
|
*/
|
|
20
22
|
onHydrated?: () => void;
|
|
21
23
|
/**
|
|
22
|
-
* Passing a new adapter reference
|
|
23
|
-
*
|
|
24
|
-
* infinite loop.
|
|
24
|
+
* Passing a new adapter reference starts over: pending values are saved to
|
|
25
|
+
* the previous adapter, then every entry is hydrated from the new one. Use a
|
|
26
|
+
* stable reference to avoid infinite loop.
|
|
25
27
|
*/
|
|
26
28
|
adapter?: Adapter;
|
|
27
29
|
}): {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -17,9 +17,8 @@ export declare function exponentialBackoffDelay(iteration: number, initialInterv
|
|
|
17
17
|
/**
|
|
18
18
|
* Returns an Observable that mirrors the source Observable with the exception
|
|
19
19
|
* of an error. If the source Observable calls error, rather than propagating
|
|
20
|
-
* the error
|
|
21
|
-
* exponentially increasing
|
|
22
|
-
*
|
|
23
|
-
* shouldRetry returns false.
|
|
20
|
+
* the error this operator resubscribes to the source Observable after a
|
|
21
|
+
* backoff delay (exponentially increasing by default). Retrying stops as soon
|
|
22
|
+
* as `retry` returns false.
|
|
24
23
|
*/
|
|
25
24
|
export declare function retryBackoff<T, TError>(config: RetryBackoffConfig<T, TError>): <T_1>(source: Observable<T_1>) => Observable<T | T_1>;
|
|
@@ -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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|