Skip to content

Commit c91db2b

Browse files
authored
Merge pull request #4555 from thoughtworks-tcaceres/invalidationBehavior
[DOCS] invalidationBehavior documentation
2 parents 75b4f69 + 6b76019 commit c91db2b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/rtk-query/internal/buildMiddleware/invalidationByTags.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const handler: ApiMiddlewareInternalHandler = (action, mwApi) => {
6464
1. invalidateTags function is called with a list of tags generated from the action metadata
6565
2. in the case of a [queryThunk] resolution an empty set of tags is always provided
6666
2. The tags calculated are added to the list of pending tags to invalidate (see [delayed](#Delayed))
67-
3. (optional: 'Delayed') the invalidateTags function is ended if the `apiSlice.invalidationBehaviour` is set to "delayed" and there are any pending thunks/queries running in that `apiSlice`
67+
3. (optional: 'Delayed') the invalidateTags function is ended if the `apiSlice.invalidationBehavior` is set to "delayed" and there are any pending thunks/queries running in that `apiSlice`
6868
4. Pending tags are reset to an empty list, if there are no tags the function ends here
6969
5. Selects all `{ endpointName, originalArgs, queryCacheKey }` combinations that would be invalidated by a specific set of tags.
7070
6. Iterates through queryCacheKeys selected and performs one of two actions if the query exists\*
@@ -102,7 +102,7 @@ Step 6 is performed within a `context.batch()` call.
102102
103103
RTKQ now has internal logic to delay tag invalidation briefly, to allow multiple invalidations to get handled together. This is controlled by a new `invalidationBehavior: 'immediate' | 'delayed'` flag on `createApi`. The new default behavior is `'delayed'`. Set it to `'immediate'` to revert to the behavior in RTK 1.9.
104104
105-
The `'delayed'` behaviour enables a check inside `invalidationByTags` that will cause any invalidation that is triggered while a query/mutation is still pending to batch the invalidation until no query/mutation is running.
105+
The `'delayed'` behavior enables a check inside `invalidationByTags` that will cause any invalidation that is triggered while a query/mutation is still pending to batch the invalidation until no query/mutation is running.
106106
107107
```ts no-transpile
108108
function invalidateTags(

packages/toolkit/src/query/createApi.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export interface CreateApiOptions<
152152
*/
153153
refetchOnReconnect?: boolean
154154
/**
155-
* Defaults to `'immediately'`. This setting allows you to control when tags are invalidated after a mutation.
155+
* Defaults to `'delayed'`. This setting allows you to control when tags are invalidated after a mutation.
156156
*
157157
* - `'immediately'`: Queries are invalidated instantly after the mutation finished, even if they are running.
158158
* If the query provides tags that were invalidated while it ran, it won't be re-fetched.

0 commit comments

Comments
 (0)