@@ -39,7 +39,7 @@ import type {
39
39
ThunkDispatch ,
40
40
AsyncThunk ,
41
41
} from '@reduxjs/toolkit'
42
- import { createAsyncThunk } from '@reduxjs/toolkit'
42
+ import { createAsyncThunk , SHOULD_AUTOBATCH } from '@reduxjs/toolkit'
43
43
44
44
import { HandledError } from '../HandledError'
45
45
@@ -123,13 +123,18 @@ export interface MutationThunkArg {
123
123
export type ThunkResult = unknown
124
124
125
125
export type ThunkApiMetaConfig = {
126
- pendingMeta : { startedTimeStamp : number }
126
+ pendingMeta : {
127
+ startedTimeStamp : number
128
+ [ SHOULD_AUTOBATCH ] : true
129
+ }
127
130
fulfilledMeta : {
128
131
fulfilledTimeStamp : number
129
132
baseQueryMeta : unknown
133
+ [ SHOULD_AUTOBATCH ] : true
130
134
}
131
135
rejectedMeta : {
132
136
baseQueryMeta : unknown
137
+ [ SHOULD_AUTOBATCH ] : true
133
138
}
134
139
}
135
140
export type QueryThunk = AsyncThunk <
@@ -399,6 +404,7 @@ export function buildThunks<
399
404
{
400
405
fulfilledTimeStamp : Date . now ( ) ,
401
406
baseQueryMeta : result . meta ,
407
+ [ SHOULD_AUTOBATCH ] : true ,
402
408
}
403
409
)
404
410
} catch ( error ) {
@@ -423,7 +429,7 @@ export function buildThunks<
423
429
catchedError . meta ,
424
430
arg . originalArgs
425
431
) ,
426
- { baseQueryMeta : catchedError . meta }
432
+ { baseQueryMeta : catchedError . meta , [ SHOULD_AUTOBATCH ] : true }
427
433
)
428
434
} catch ( e ) {
429
435
catchedError = e
@@ -473,7 +479,7 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
473
479
ThunkApiMetaConfig & { state : RootState < any , string , ReducerPath > }
474
480
> ( `${ reducerPath } /executeQuery` , executeEndpoint , {
475
481
getPendingMeta ( ) {
476
- return { startedTimeStamp : Date . now ( ) }
482
+ return { startedTimeStamp : Date . now ( ) , [ SHOULD_AUTOBATCH ] : true }
477
483
} ,
478
484
condition ( queryThunkArgs , { getState } ) {
479
485
const state = getState ( )
@@ -532,7 +538,7 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
532
538
ThunkApiMetaConfig & { state : RootState < any , string , ReducerPath > }
533
539
> ( `${ reducerPath } /executeMutation` , executeEndpoint , {
534
540
getPendingMeta ( ) {
535
- return { startedTimeStamp : Date . now ( ) }
541
+ return { startedTimeStamp : Date . now ( ) , [ SHOULD_AUTOBATCH ] : true }
536
542
} ,
537
543
} )
538
544
0 commit comments