Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions packages/toolkit/src/query/react/buildHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ export type UseQuerySubscriptionOptions = SubscriptionOptions & {
refetchOnMountOrArgChange?: boolean | number
}

/**
* Provides a way to reference the options accepted by the `useQuerySubscription`
* hook in userland code.
*
* Unlike other `Typed*` wrappers, this type has no generic parameters since
* {@linkcode UseQuerySubscriptionOptions} does not depend on a specific query
* definition.
*
* @since 2.2.8
* @public
*/
export type TypedUseQuerySubscriptionOptions = UseQuerySubscriptionOptions

/**
* A React hook that automatically triggers fetches of data from an endpoint, and 'subscribes' the component to the cached data.
*
Expand Down Expand Up @@ -1337,6 +1350,30 @@ export type UseMutationStateOptions<
fixedCacheKey?: string
}

/**
* Provides a way to define a "pre-typed" version of
* {@linkcode UseMutationStateOptions} with specific options for a given mutation.
*
* @template ResultType - The type of the result `data` returned by the mutation.
* @template QueryArg - The type of the argument passed into the mutation.
* @template BaseQuery - The type of the base query function being used.
* @template SelectedResult - The type of the selected result returned by the __`selectFromResult`__ function.
*
* @since 2.2.8
* @public
*/
export type TypedUseMutationStateOptions<
ResultType,
QueryArg,
BaseQuery extends BaseQueryFn,
SelectedResult extends Record<string, any> = MutationResultSelectorResult<
MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>
>,
> = UseMutationStateOptions<
MutationDefinition<QueryArg, BaseQuery, string, ResultType, string>,
SelectedResult
>

export type UseMutationStateResult<
D extends MutationDefinition<any, any, any, any>,
R,
Expand Down
2 changes: 2 additions & 0 deletions packages/toolkit/src/query/react/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export type {
TypedUseInfiniteQuerySubscription,
TypedUseInfiniteQueryState,
TypedLazyInfiniteQueryTrigger,
TypedUseQuerySubscriptionOptions,
TypedUseMutationStateOptions,
} from './buildHooks'
export { UNINITIALIZED_VALUE } from './constants'
export { createApi, reactHooksModule, reactHooksModuleName }
Loading