@hyper-fetch/react 9.1.0 → 9.3.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/__tests__/features/helpers/use-request-events/use-request-events.base.spec.ts +2 -2
- package/__tests__/features/strict-mode/strict-mode.requests.spec.ts +45 -0
- package/__tests__/features/strict-mode/strict-mode.sockets.spec.ts +21 -0
- package/__tests__/features/use-cache/use-cache.select.spec.tsx +117 -0
- package/__tests__/features/use-cache/use-cache.typescript.spec.ts +10 -0
- package/__tests__/features/use-fetch/use-fetch.refresh.spec.ts +17 -14
- package/__tests__/features/use-fetch/use-fetch.select.spec.tsx +420 -0
- package/__tests__/features/use-fetch/use-fetch.throw-on-error.spec.tsx +213 -0
- package/__tests__/features/use-fetch/use-fetch.typescript.spec.ts +41 -0
- package/__tests__/features/use-is-fetching/use-is-fetching.base.spec.tsx +117 -0
- package/__tests__/features/use-listener/use-listener.select.spec.tsx +183 -0
- package/__tests__/features/use-listener/use-listener.typescript.spec.ts +23 -0
- package/__tests__/features/use-submit/use-submit.select.spec.tsx +55 -0
- package/__tests__/features/use-submit/use-submit.typescript.spec.ts +14 -0
- package/__tests__/utils/use-fetch.utils.ts +4 -1
- package/dist/helpers/use-request-events/use-request-events.types.d.ts +1 -1
- package/dist/helpers/use-request-events/use-request-events.types.d.ts.map +1 -1
- package/dist/helpers/use-socket-state/use-socket-state.hooks.d.ts +2 -0
- package/dist/helpers/use-socket-state/use-socket-state.hooks.d.ts.map +1 -1
- package/dist/helpers/use-tracked-state/use-tracked-state.hooks.d.ts +2 -2
- package/dist/helpers/use-tracked-state/use-tracked-state.hooks.d.ts.map +1 -1
- package/dist/helpers/use-tracked-state/use-tracked-state.types.d.ts +23 -10
- package/dist/helpers/use-tracked-state/use-tracked-state.types.d.ts.map +1 -1
- package/dist/hooks/use-cache/use-cache.constants.d.ts +1 -0
- package/dist/hooks/use-cache/use-cache.constants.d.ts.map +1 -1
- package/dist/hooks/use-cache/use-cache.hooks.d.ts +2 -2
- package/dist/hooks/use-cache/use-cache.hooks.d.ts.map +1 -1
- package/dist/hooks/use-cache/use-cache.types.d.ts +12 -3
- package/dist/hooks/use-cache/use-cache.types.d.ts.map +1 -1
- package/dist/hooks/use-fetch/use-fetch.constants.d.ts +1 -1
- package/dist/hooks/use-fetch/use-fetch.constants.d.ts.map +1 -1
- package/dist/hooks/use-fetch/use-fetch.hooks.d.ts +2 -2
- package/dist/hooks/use-fetch/use-fetch.hooks.d.ts.map +1 -1
- package/dist/hooks/use-fetch/use-fetch.types.d.ts +18 -4
- package/dist/hooks/use-fetch/use-fetch.types.d.ts.map +1 -1
- package/dist/hooks/use-is-fetching/index.d.ts +3 -0
- package/dist/hooks/use-is-fetching/index.d.ts.map +1 -0
- package/dist/hooks/use-is-fetching/use-is-fetching.hooks.d.ts +17 -0
- package/dist/hooks/use-is-fetching/use-is-fetching.hooks.d.ts.map +1 -0
- package/dist/hooks/use-is-fetching/use-is-fetching.types.d.ts +12 -0
- package/dist/hooks/use-is-fetching/use-is-fetching.types.d.ts.map +1 -0
- package/dist/hooks/use-listener/use-listener.hooks.d.ts +3 -3
- package/dist/hooks/use-listener/use-listener.hooks.d.ts.map +1 -1
- package/dist/hooks/use-listener/use-listener.types.d.ts +12 -1
- package/dist/hooks/use-listener/use-listener.types.d.ts.map +1 -1
- package/dist/hooks/use-submit/use-submit.constants.d.ts +1 -1
- package/dist/hooks/use-submit/use-submit.constants.d.ts.map +1 -1
- package/dist/hooks/use-submit/use-submit.hooks.d.ts +2 -2
- package/dist/hooks/use-submit/use-submit.hooks.d.ts.map +1 -1
- package/dist/hooks/use-submit/use-submit.types.d.ts +13 -4
- package/dist/hooks/use-submit/use-submit.types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +181 -35
- package/dist/index.mjs.map +1 -1
- package/dist/provider/provider.types.d.ts +6 -4
- package/dist/provider/provider.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/helpers/use-request-events/use-request-events.types.ts +1 -1
- package/src/helpers/use-socket-state/use-socket-state.hooks.ts +3 -1
- package/src/helpers/use-tracked-state/use-tracked-state.hooks.ts +112 -26
- package/src/helpers/use-tracked-state/use-tracked-state.types.ts +27 -9
- package/src/hooks/use-cache/use-cache.constants.ts +1 -0
- package/src/hooks/use-cache/use-cache.hooks.ts +9 -7
- package/src/hooks/use-cache/use-cache.types.ts +16 -4
- package/src/hooks/use-emitter/use-emitter.hooks.ts +1 -1
- package/src/hooks/use-fetch/use-fetch.constants.ts +3 -1
- package/src/hooks/use-fetch/use-fetch.hooks.ts +38 -6
- package/src/hooks/use-fetch/use-fetch.types.ts +33 -5
- package/src/hooks/use-is-fetching/index.ts +2 -0
- package/src/hooks/use-is-fetching/use-is-fetching.hooks.ts +51 -0
- package/src/hooks/use-is-fetching/use-is-fetching.types.ts +12 -0
- package/src/hooks/use-listener/use-listener.hooks.ts +61 -6
- package/src/hooks/use-listener/use-listener.types.ts +12 -1
- package/src/hooks/use-submit/use-submit.constants.ts +2 -1
- package/src/hooks/use-submit/use-submit.hooks.ts +22 -7
- package/src/hooks/use-submit/use-submit.types.ts +23 -7
- package/src/index.ts +1 -0
- package/src/provider/provider.types.ts +8 -4
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AdapterInstance, ClientInstance, Dispatcher } from "@hyper-fetch/core";
|
|
2
|
+
import type { UseIsFetchingOptionsType } from "hooks/use-is-fetching";
|
|
3
|
+
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
4
|
+
|
|
5
|
+
const useRunningRequestsCount = (
|
|
6
|
+
dispatcher: Dispatcher<AdapterInstance>,
|
|
7
|
+
options?: UseIsFetchingOptionsType,
|
|
8
|
+
): number => {
|
|
9
|
+
const optionsRef = useRef(options);
|
|
10
|
+
optionsRef.current = options;
|
|
11
|
+
|
|
12
|
+
const subscribe = useCallback(
|
|
13
|
+
(listener: () => void) => dispatcher.events.onRunningRequestsChange(listener),
|
|
14
|
+
[dispatcher],
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const getCount = () => {
|
|
18
|
+
const { queryKey, predicate } = optionsRef.current || {};
|
|
19
|
+
return dispatcher.getAllRunningRequests().filter(({ request }) => {
|
|
20
|
+
if (typeof queryKey === "string" && request.queryKey !== queryKey) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (queryKey instanceof RegExp && !queryKey.test(request.queryKey)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return !predicate || predicate(request);
|
|
27
|
+
}).length;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return useSyncExternalStore(subscribe, getCount, getCount);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Count of the currently running fetch requests (useFetch, useCache and fetch dispatcher). Useful for global loading indicators.
|
|
35
|
+
* @param client Client instance
|
|
36
|
+
* @param options Filters for the counted requests
|
|
37
|
+
* @returns number of running requests
|
|
38
|
+
*/
|
|
39
|
+
export const useIsFetching = (client: ClientInstance, options?: UseIsFetchingOptionsType): number => {
|
|
40
|
+
return useRunningRequestsCount(client.fetchDispatcher, options);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Count of the currently running submit requests (useSubmit and submit dispatcher). Useful for global saving indicators.
|
|
45
|
+
* @param client Client instance
|
|
46
|
+
* @param options Filters for the counted requests
|
|
47
|
+
* @returns number of running requests
|
|
48
|
+
*/
|
|
49
|
+
export const useIsSubmitting = (client: ClientInstance, options?: UseIsFetchingOptionsType): number => {
|
|
50
|
+
return useRunningRequestsCount(client.submitDispatcher, options);
|
|
51
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RequestInstance } from "@hyper-fetch/core";
|
|
2
|
+
|
|
3
|
+
export type UseIsFetchingOptionsType = {
|
|
4
|
+
/**
|
|
5
|
+
* Count only the requests with matching queryKey - exact string or RegExp
|
|
6
|
+
*/
|
|
7
|
+
queryKey?: string | RegExp;
|
|
8
|
+
/**
|
|
9
|
+
* Count only the requests for which the predicate returns true
|
|
10
|
+
*/
|
|
11
|
+
predicate?: (request: RequestInstance) => boolean;
|
|
12
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useDidUpdate, useWillUnmount } from "@better-hooks/lifecycle";
|
|
2
|
+
import { replaceEqualDeep } from "@hyper-fetch/core";
|
|
2
3
|
import type { ListenerInstance, ExtractListenerDeliveredType } from "@hyper-fetch/sockets";
|
|
3
4
|
import { getDeliveryKey } from "@hyper-fetch/sockets";
|
|
4
5
|
import { useSocketState } from "helpers";
|
|
@@ -8,18 +9,56 @@ import { useRef } from "react";
|
|
|
8
9
|
import { createTrackedProxy } from "utils";
|
|
9
10
|
|
|
10
11
|
/** Subscribe to incoming socket messages on a given listener topic with tracked connection state and callbacks. */
|
|
11
|
-
export const useListener = <
|
|
12
|
+
export const useListener = <
|
|
13
|
+
ListenerType extends ListenerInstance,
|
|
14
|
+
TSelected = ExtractListenerDeliveredType<ListenerType>,
|
|
15
|
+
>(
|
|
12
16
|
listener: ListenerType,
|
|
13
|
-
options?: UseListenerOptionsType
|
|
17
|
+
options?: UseListenerOptionsType<ExtractListenerDeliveredType<ListenerType>, TSelected>,
|
|
14
18
|
) => {
|
|
15
19
|
const { config: globalConfig } = useProvider();
|
|
16
|
-
const { dependencyTracking } = { ...globalConfig.useListener, ...options };
|
|
17
|
-
const
|
|
18
|
-
|
|
20
|
+
const { dependencyTracking = true, structuralSharing = true } = { ...globalConfig.useListener, ...options };
|
|
21
|
+
const select = options?.select;
|
|
22
|
+
const [state, actions, callbacks, { setRenderKey, getState, rerender }] = useSocketState<
|
|
23
|
+
TSelected,
|
|
19
24
|
ListenerType["socket"]
|
|
20
25
|
>(listener.socket, { dependencyTracking });
|
|
21
26
|
const removeListenerRef = useRef<ReturnType<typeof listener.listen> | null>(null);
|
|
22
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Selection
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
const selectRef = useRef(select);
|
|
33
|
+
selectRef.current = select;
|
|
34
|
+
const appliedSelect = useRef(select);
|
|
35
|
+
// Last message data before applying the selector - allows to re-run it when the selector changes
|
|
36
|
+
const rawData = useRef<{ data: ExtractListenerDeliveredType<ListenerType> } | null>(null);
|
|
37
|
+
const selectError = useRef<{ error: unknown } | null>(null);
|
|
38
|
+
|
|
39
|
+
const selectData = (data: ExtractListenerDeliveredType<ListenerType>): TSelected => {
|
|
40
|
+
if (!selectRef.current) {
|
|
41
|
+
return data as unknown as TSelected;
|
|
42
|
+
}
|
|
43
|
+
const selected = selectRef.current(data);
|
|
44
|
+
return structuralSharing ? replaceEqualDeep(getState().data, selected) : selected;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Selector failed while processing a message - surface it to the closest error boundary
|
|
48
|
+
if (selectError.current) {
|
|
49
|
+
const { error } = selectError.current;
|
|
50
|
+
selectError.current = null;
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Selector changed (e.g. it closes over a new prop) - re-run it against the last message
|
|
55
|
+
if (appliedSelect.current !== select) {
|
|
56
|
+
appliedSelect.current = select;
|
|
57
|
+
if (rawData.current) {
|
|
58
|
+
state.data = selectData(rawData.current.data);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
23
62
|
/**
|
|
24
63
|
* Callbacks
|
|
25
64
|
*/
|
|
@@ -40,7 +79,23 @@ export const useListener = <ListenerType extends ListenerInstance>(
|
|
|
40
79
|
stopListener();
|
|
41
80
|
removeListenerRef.current = listener.listen(({ data, extra }) => {
|
|
42
81
|
onEventCallback.current?.({ data, extra });
|
|
43
|
-
|
|
82
|
+
rawData.current = { data };
|
|
83
|
+
appliedSelect.current = selectRef.current;
|
|
84
|
+
|
|
85
|
+
let selected: TSelected;
|
|
86
|
+
try {
|
|
87
|
+
selected = selectData(data);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
// Never throw inside of the socket events - rethrow it on render instead
|
|
90
|
+
selectError.current = { error };
|
|
91
|
+
rerender();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// With a selector, data is updated only when the selected value changed
|
|
96
|
+
if (!selectRef.current || !Object.is(selected, getState().data)) {
|
|
97
|
+
actions.setData(selected);
|
|
98
|
+
}
|
|
44
99
|
actions.setExtra(extra);
|
|
45
100
|
actions.setTimestamp(Date.now());
|
|
46
101
|
});
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
export type UseListenerOptionsType = {
|
|
1
|
+
export type UseListenerOptionsType<DataType = any, TSelected = DataType> = {
|
|
2
2
|
/** When true (default), only re-renders when accessed state properties change */
|
|
3
3
|
dependencyTracking?: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Pick or transform the part of the message data used by the component.
|
|
6
|
+
* With a selector the `data` value updates only when the selected value changes,
|
|
7
|
+
* so components reading `data` rerender only for the relevant messages.
|
|
8
|
+
*/
|
|
9
|
+
select?: (data: DataType) => TSelected;
|
|
10
|
+
/**
|
|
11
|
+
* Keep references of the unchanged parts of the selected data between messages (default true).
|
|
12
|
+
* Applies to the `select` result - without a selector every message updates the data.
|
|
13
|
+
*/
|
|
14
|
+
structuralSharing?: boolean;
|
|
4
15
|
};
|
|
@@ -2,7 +2,7 @@ import type { RequestInstance, RequiredKeys } from "@hyper-fetch/core";
|
|
|
2
2
|
|
|
3
3
|
import type { UseSubmitOptionsType } from "./use-submit.types";
|
|
4
4
|
|
|
5
|
-
type DefaultOptionsType = RequiredKeys<Omit<UseSubmitOptionsType<RequestInstance>, "initialResponse">> & {
|
|
5
|
+
type DefaultOptionsType = RequiredKeys<Omit<UseSubmitOptionsType<RequestInstance>, "initialResponse" | "select">> & {
|
|
6
6
|
initialResponse: null;
|
|
7
7
|
};
|
|
8
8
|
|
|
@@ -14,4 +14,5 @@ export const useSubmitDefaultOptions: DefaultOptionsType = {
|
|
|
14
14
|
bounceType: "debounce",
|
|
15
15
|
bounceTime: 400,
|
|
16
16
|
deepCompare: true,
|
|
17
|
+
structuralSharing: true,
|
|
17
18
|
};
|
|
@@ -25,13 +25,13 @@ import { createTrackedProxy, getBounceData } from "utils";
|
|
|
25
25
|
* @param options
|
|
26
26
|
* @returns
|
|
27
27
|
*/
|
|
28
|
-
export const useSubmit = <RequestType extends RequestInstance
|
|
28
|
+
export const useSubmit = <RequestType extends RequestInstance, TSelected = ExtractResponseType<RequestType>>(
|
|
29
29
|
request: RequestType,
|
|
30
|
-
options?: UseSubmitOptionsType<RequestType>,
|
|
31
|
-
): UseSubmitReturnType<RequestType> => {
|
|
30
|
+
options?: UseSubmitOptionsType<RequestType, TSelected>,
|
|
31
|
+
): UseSubmitReturnType<RequestType, TSelected> => {
|
|
32
32
|
// Build the configuration options
|
|
33
33
|
const { config: globalConfig } = useProvider();
|
|
34
|
-
const mergedOptions: UseSubmitOptionsType<RequestType> = useMemo(
|
|
34
|
+
const mergedOptions: UseSubmitOptionsType<RequestType, TSelected> = useMemo(
|
|
35
35
|
() => ({
|
|
36
36
|
...useSubmitDefaultOptions,
|
|
37
37
|
...globalConfig.useSubmitConfig,
|
|
@@ -40,7 +40,16 @@ export const useSubmit = <RequestType extends RequestInstance>(
|
|
|
40
40
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
41
|
[globalConfig.useSubmitConfig, JSON.stringify(options), options?.deepCompare],
|
|
42
42
|
);
|
|
43
|
-
const {
|
|
43
|
+
const {
|
|
44
|
+
disabled,
|
|
45
|
+
dependencyTracking,
|
|
46
|
+
initialResponse,
|
|
47
|
+
bounce,
|
|
48
|
+
bounceType,
|
|
49
|
+
bounceTime,
|
|
50
|
+
deepCompare,
|
|
51
|
+
structuralSharing,
|
|
52
|
+
} = mergedOptions;
|
|
44
53
|
|
|
45
54
|
/**
|
|
46
55
|
* Because of the dynamic cacheKey / queryKey signing within the request we need to store it's latest instance
|
|
@@ -71,13 +80,19 @@ export const useSubmit = <RequestType extends RequestInstance>(
|
|
|
71
80
|
/**
|
|
72
81
|
* State handler with optimization for rerendering, that hooks into the cache state and dispatchers queues
|
|
73
82
|
*/
|
|
74
|
-
const [state, actions, { setRenderKey, setCacheData, getIsDataProcessing }] = useTrackedState<
|
|
83
|
+
const [state, actions, { setRenderKey, setCacheData, getIsDataProcessing }] = useTrackedState<
|
|
84
|
+
RequestType,
|
|
85
|
+
TSelected
|
|
86
|
+
>({
|
|
75
87
|
logger,
|
|
76
88
|
request,
|
|
77
89
|
dispatcher,
|
|
78
90
|
initialResponse,
|
|
79
91
|
deepCompare: deepCompare as boolean,
|
|
80
92
|
dependencyTracking: dependencyTracking as boolean,
|
|
93
|
+
// Read directly from options - functions are not part of the memoized options key
|
|
94
|
+
select: options?.select,
|
|
95
|
+
structuralSharing,
|
|
81
96
|
});
|
|
82
97
|
|
|
83
98
|
/**
|
|
@@ -239,5 +254,5 @@ export const useSubmit = <RequestType extends RequestInstance>(
|
|
|
239
254
|
},
|
|
240
255
|
trackedKeys,
|
|
241
256
|
setSubmitRenderKey,
|
|
242
|
-
) as UseSubmitReturnType<RequestType>;
|
|
257
|
+
) as UseSubmitReturnType<RequestType, TSelected>;
|
|
243
258
|
};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ExtractAdapterResolvedType,
|
|
3
|
+
ExtractResponseType,
|
|
4
|
+
NullableType,
|
|
5
|
+
RequestInstance,
|
|
6
|
+
RequestSendType,
|
|
7
|
+
} from "@hyper-fetch/core";
|
|
2
8
|
import type {
|
|
3
9
|
OnProgressCallbackType,
|
|
4
10
|
OnStartCallbackType,
|
|
@@ -7,10 +13,11 @@ import type {
|
|
|
7
13
|
OnFinishedCallbackType,
|
|
8
14
|
UseTrackedStateType,
|
|
9
15
|
UseTrackedStateActions,
|
|
16
|
+
UseTrackedStateSelect,
|
|
10
17
|
} from "helpers";
|
|
11
18
|
import type { isEqual } from "utils";
|
|
12
19
|
|
|
13
|
-
export type UseSubmitOptionsType<T extends RequestInstance
|
|
20
|
+
export type UseSubmitOptionsType<T extends RequestInstance, TSelected = ExtractResponseType<T>> = {
|
|
14
21
|
/**
|
|
15
22
|
* Disable submitting
|
|
16
23
|
*/
|
|
@@ -31,6 +38,15 @@ export type UseSubmitOptionsType<T extends RequestInstance> = {
|
|
|
31
38
|
* Deep comparison function for hook to check for equality in incoming data, to limit rerenders.
|
|
32
39
|
*/
|
|
33
40
|
deepCompare?: boolean | typeof isEqual;
|
|
41
|
+
/**
|
|
42
|
+
* Pick or transform the part of the response data used by the component.
|
|
43
|
+
* Callbacks like `onSubmitSuccess` still receive the full response.
|
|
44
|
+
*/
|
|
45
|
+
select?: UseTrackedStateSelect<T, TSelected>;
|
|
46
|
+
/**
|
|
47
|
+
* Keep references of the unchanged parts of the selected data between updates (default true).
|
|
48
|
+
*/
|
|
49
|
+
structuralSharing?: boolean;
|
|
34
50
|
} & (
|
|
35
51
|
| {
|
|
36
52
|
/**
|
|
@@ -58,11 +74,11 @@ export type UseSubmitOptionsType<T extends RequestInstance> = {
|
|
|
58
74
|
}
|
|
59
75
|
);
|
|
60
76
|
|
|
61
|
-
export type UseSubmitReturnType<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
> &
|
|
65
|
-
UseTrackedStateActions<RequestType> & {
|
|
77
|
+
export type UseSubmitReturnType<
|
|
78
|
+
RequestType extends RequestInstance,
|
|
79
|
+
TSelected = ExtractResponseType<RequestType>,
|
|
80
|
+
> = Omit<UseTrackedStateType<RequestType, TSelected>, "loading"> &
|
|
81
|
+
UseTrackedStateActions<RequestType, TSelected> & {
|
|
66
82
|
/**
|
|
67
83
|
* Callback which allows to cancel ongoing requests from given queryKey.
|
|
68
84
|
*/
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./hooks/use-stream";
|
|
|
6
6
|
export * from "./hooks/use-listener";
|
|
7
7
|
export * from "./hooks/use-emitter";
|
|
8
8
|
export * from "./hooks/use-app-manager";
|
|
9
|
+
export * from "./hooks/use-is-fetching";
|
|
9
10
|
export * from "./helpers";
|
|
10
11
|
export * from "./provider";
|
|
11
12
|
export * from "./utils";
|
|
@@ -7,12 +7,16 @@ import type { UseQueueOptionsType } from "hooks/use-queue";
|
|
|
7
7
|
import type { UseSubmitOptionsType } from "hooks/use-submit";
|
|
8
8
|
import type React from "react";
|
|
9
9
|
|
|
10
|
+
// Omit applied to every union member - keeps the bounce options discriminated union intact
|
|
11
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
12
|
+
|
|
10
13
|
export type ProviderOptionsType = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
// Selectors are component specific, they cannot be configured globally
|
|
15
|
+
useFetchConfig?: Partial<DistributiveOmit<UseFetchOptionsType<RequestInstance>, "select">>;
|
|
16
|
+
useSubmitConfig?: Partial<DistributiveOmit<UseSubmitOptionsType<RequestInstance>, "select">>;
|
|
17
|
+
useCacheConfig?: Partial<Omit<UseCacheOptionsType<RequestInstance>, "select">>;
|
|
14
18
|
useQueueConfig?: Partial<UseQueueOptionsType>;
|
|
15
|
-
useListener?: Partial<UseListenerOptionsType
|
|
19
|
+
useListener?: Partial<Omit<UseListenerOptionsType, "select">>;
|
|
16
20
|
useEmitter?: Partial<UseEmitterOptionsType>;
|
|
17
21
|
};
|
|
18
22
|
|