reactjrx 1.142.3 → 1.143.0
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/useSubscribeEffect.d.ts +28 -4
- package/dist/lib/queries/QueryClientProvider$.d.ts +1 -1
- package/dist/lib/queries/useQuery$.d.ts +1 -1
- 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/SignalContextProvider.d.ts +1 -1
- package/dist/lib/state/react/usePersistSignals.d.ts +8 -2
- package/dist/tests/liveQuery.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
import { SubscribeSource } from './useSubscribe/types';
|
|
2
|
-
interface
|
|
3
|
-
|
|
2
|
+
export interface UseSubscribeEffectOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Called on every error of the source, including the ones that are
|
|
5
|
+
* retried.
|
|
6
|
+
*/
|
|
4
7
|
onError?: (error: unknown) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Whether to subscribe to the source again after an error:
|
|
10
|
+
* - `false` (default): the error ends the subscription;
|
|
11
|
+
* - `true`: retry without limit;
|
|
12
|
+
* - a number: retry at most that many times in a row;
|
|
13
|
+
* - a function: given the attempt (0 for the first retry) and the error,
|
|
14
|
+
* returns whether to retry.
|
|
15
|
+
*
|
|
16
|
+
* The attempt count goes back to 0 once the source emits again.
|
|
17
|
+
*/
|
|
18
|
+
retry?: boolean | number | ((attempt: number, error: unknown) => boolean);
|
|
19
|
+
/**
|
|
20
|
+
* Time to wait before each retry, in milliseconds, or a function of the
|
|
21
|
+
* attempt and the error. Retries always wait for a timer, so they never
|
|
22
|
+
* run synchronously, even with `0`. Defaults to an exponential backoff:
|
|
23
|
+
* 1 s, 2 s, 4 s… up to 30 s.
|
|
24
|
+
*/
|
|
25
|
+
retryDelay?: number | ((attempt: number, error: unknown) => number);
|
|
5
26
|
}
|
|
6
|
-
|
|
7
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Subscribes to `source` while the component is mounted. Options are read
|
|
29
|
+
* at each error, so changing them never subscribes again.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useSubscribeEffect<T>(source: SubscribeSource<T>, options?: UseSubscribeEffectOptions): void;
|
|
@@ -36,6 +36,6 @@ export declare const Context: import('react').Context<QueryClient$ | undefined>;
|
|
|
36
36
|
export declare const QueryClientProvider$: import('react').MemoExoticComponent<({ children, client: _client, }: {
|
|
37
37
|
children: React.ReactNode;
|
|
38
38
|
client?: QueryClient$;
|
|
39
|
-
}) => import(
|
|
39
|
+
}) => import('react').JSX.Element>;
|
|
40
40
|
export declare const useQueryClient$: () => QueryClient$;
|
|
41
41
|
export {};
|
|
@@ -2,4 +2,4 @@ import { DefaultError, QueryClient, QueryKey, UseQueryOptions } from '@tanstack/
|
|
|
2
2
|
import { ObservableQueryFn } from './createObservableQueryFn';
|
|
3
3
|
export declare function useQuery$<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>({ queryFn, ...options }: Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, "queryFn"> & {
|
|
4
4
|
queryFn: ObservableQueryFn<TQueryFnData, TQueryKey>;
|
|
5
|
-
}, queryClient?: QueryClient): import('@tanstack/react-query').UseQueryResult<
|
|
5
|
+
}, queryClient?: QueryClient): import('@tanstack/react-query').UseQueryResult<TData, TError>;
|
|
@@ -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
|
}>;
|
|
@@ -4,6 +4,6 @@ export type SignalContextType = SignalContext;
|
|
|
4
4
|
export declare const SignalReactContext: import('react').Context<SignalContext>;
|
|
5
5
|
export declare const SignalContextProvider: import('react').MemoExoticComponent<({ children }: {
|
|
6
6
|
children: React.ReactNode;
|
|
7
|
-
}) => import(
|
|
7
|
+
}) => import('react').JSX.Element>;
|
|
8
8
|
export declare const useSignalContext: () => SignalContext;
|
|
9
9
|
export declare const useMakeOrRetrieveSignal: (virtualSignal?: VirtualSignal<unknown>) => import('../Signal').Signal<unknown, undefined> | undefined;
|
|
@@ -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
|
}): {
|
|
@@ -17,4 +17,4 @@ export declare function createLiveQuerySource(initialItems: string[]): {
|
|
|
17
17
|
};
|
|
18
18
|
export declare function createWrapper(queryClient: QueryClient): ({ children }: {
|
|
19
19
|
children: React.ReactNode;
|
|
20
|
-
}) =>
|
|
20
|
+
}) => React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactjrx",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.143.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"rxjs": "*"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@biomejs/biome": "2.
|
|
42
|
+
"@biomejs/biome": "2.5.15",
|
|
43
43
|
"@rolldown/plugin-babel": "^0.2.3",
|
|
44
44
|
"@tanstack/react-query-persist-client": "^5.96.2",
|
|
45
45
|
"@testing-library/jest-dom": "^7.0.0",
|