Skip to content

Commit

Permalink
Rename OnQueryStarted types
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Nov 23, 2024
1 parent 2199c0a commit 602cd20
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/toolkit/src/query/core/buildMiddleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export type {
MutationLifecycleApi,
QueryLifecycleApi,
ReferenceQueryLifecycle,
TypedOnQueryStartedForMutationEndpoints,
TypedOnQueryStartedForQueryEndpoints,
TypedMutationOnQueryStarted,
TypedQueryOnQueryStarted,
} from './queryLifecycle'
export type { SubscriptionSelectors } from './types'

Expand Down
26 changes: 18 additions & 8 deletions packages/toolkit/src/query/core/buildMiddleware/queryLifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ export type QueryLifecycleQueryExtraOptions<
*/
onQueryStarted?(
queryArgument: QueryArg,
queryLifeCycleApi: QueryLifecycleApi<QueryArg, BaseQuery, ResultType, ReducerPath>,
queryLifeCycleApi: QueryLifecycleApi<
QueryArg,
BaseQuery,
ResultType,
ReducerPath
>,
): Promise<void> | void
}

Expand Down Expand Up @@ -172,7 +177,12 @@ export type QueryLifecycleMutationExtraOptions<
*/
onQueryStarted?(
queryArgument: QueryArg,
mutationLifeCycleApi: MutationLifecycleApi<QueryArg, BaseQuery, ResultType, ReducerPath>,
mutationLifeCycleApi: MutationLifecycleApi<
QueryArg,
BaseQuery,
ResultType,
ReducerPath
>,
): Promise<void> | void
}

Expand Down Expand Up @@ -201,7 +211,7 @@ export type MutationLifecycleApi<
* <caption>#### __Create and reuse a strongly-typed `onQueryStarted` function__</caption>
*
* ```ts
* import type { TypedOnQueryStartedForQueryEndpoints } from '@reduxjs/toolkit/query'
* import type { TypedQueryOnQueryStarted } from '@reduxjs/toolkit/query'
* import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'
*
* type Post = {
Expand Down Expand Up @@ -236,7 +246,7 @@ export type MutationLifecycleApi<
* }),
* })
*
* const updatePostOnFulfilled: TypedOnQueryStartedForQueryEndpoints<
* const updatePostOnFulfilled: TypedQueryOnQueryStarted<
* PostsApiResponse,
* QueryArgument,
* BaseQueryFunction,
Expand Down Expand Up @@ -278,7 +288,7 @@ export type MutationLifecycleApi<
* @since 2.4.0
* @public
*/
export type TypedOnQueryStartedForQueryEndpoints<
export type TypedQueryOnQueryStarted<
ResultType,
QueryArgumentType,
BaseQueryFunctionType extends BaseQueryFn,
Expand All @@ -299,7 +309,7 @@ export type TypedOnQueryStartedForQueryEndpoints<
* <caption>#### __Create and reuse a strongly-typed `onQueryStarted` function__</caption>
*
* ```ts
* import type { TypedOnQueryStartedForMutationEndpoints } from '@reduxjs/toolkit/query'
* import type { TypedMutationOnQueryStarted } from '@reduxjs/toolkit/query'
* import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'
*
* type Post = {
Expand Down Expand Up @@ -334,7 +344,7 @@ export type TypedOnQueryStartedForQueryEndpoints<
* }),
* })
*
* const updatePostOnFulfilled: TypedOnQueryStartedForMutationEndpoints<
* const updatePostOnFulfilled: TypedMutationOnQueryStarted<
* Post,
* QueryArgument,
* BaseQueryFunction,
Expand Down Expand Up @@ -386,7 +396,7 @@ export type TypedOnQueryStartedForQueryEndpoints<
* @since 2.4.0
* @public
*/
export type TypedOnQueryStartedForMutationEndpoints<
export type TypedMutationOnQueryStarted<
ResultType,
QueryArgumentType,
BaseQueryFunctionType extends BaseQueryFn,
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/query/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export type {
QueryCacheLifecycleApi,
QueryLifecycleApi,
SubscriptionSelectors,
TypedOnQueryStartedForMutationEndpoints,
TypedOnQueryStartedForQueryEndpoints,
TypedMutationOnQueryStarted,
TypedQueryOnQueryStarted,
} from './buildMiddleware/index'
export { skipToken } from './buildSelectors'
export type {
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export { _NEVER, fakeBaseQuery } from './fakeBaseQuery'
export { copyWithStructuralSharing } from './utils/copyWithStructuralSharing'
export { createApi, coreModule, coreModuleName } from './core/index'
export type {
TypedOnQueryStartedForMutationEndpoints,
TypedOnQueryStartedForQueryEndpoints,
TypedMutationOnQueryStarted,
TypedQueryOnQueryStarted,
} from './core/index'
export type {
ApiEndpointMutation,
Expand Down
12 changes: 6 additions & 6 deletions packages/toolkit/src/query/tests/queryLifecycle.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type {
FetchBaseQueryError,
FetchBaseQueryMeta,
RootState,
TypedOnQueryStartedForMutationEndpoints,
TypedOnQueryStartedForQueryEndpoints,
TypedMutationOnQueryStarted,
TypedQueryOnQueryStarted,
} from '@reduxjs/toolkit/query'
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query'

Expand Down Expand Up @@ -155,7 +155,7 @@ describe('type tests', () => {
})

describe('typed `onQueryStarted` function', () => {
test('TypedOnQueryStartedForQueryEndpoints creates a pre-typed version of onQueryStarted', () => {
test('TypedQueryOnQueryStarted creates a pre-typed version of onQueryStarted', () => {
type Post = {
id: number
title: string
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('type tests', () => {
}),
})

const updatePostOnFulfilled: TypedOnQueryStartedForQueryEndpoints<
const updatePostOnFulfilled: TypedQueryOnQueryStarted<
PostsApiResponse,
QueryArgument,
BaseQueryFunction,
Expand Down Expand Up @@ -256,7 +256,7 @@ describe('type tests', () => {
})
})

test('TypedOnQueryStartedForMutationEndpoints creates a pre-typed version of onQueryStarted', () => {
test('TypedMutationOnQueryStarted creates a pre-typed version of onQueryStarted', () => {
type Post = {
id: number
title: string
Expand Down Expand Up @@ -289,7 +289,7 @@ describe('type tests', () => {
}),
})

const updatePostOnFulfilled: TypedOnQueryStartedForMutationEndpoints<
const updatePostOnFulfilled: TypedMutationOnQueryStarted<
Post,
QueryArgument,
BaseQueryFunction,
Expand Down

0 comments on commit 602cd20

Please sign in to comment.