Skip to content

Commit ca0b28e

Browse files
dutziworksmarkerikson
authored andcommittedSep 24, 2023
update docs
1 parent bd7f3ba commit ca0b28e

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed
 

‎docs/rtk-query/api/created-api/api-slice-utils.mdx

+28-24
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Some of the TS types on this page are pseudocode to illustrate intent, as the ac
2929
const updateQueryData = (
3030
endpointName: string,
3131
args: any,
32-
updateRecipe: (draft: Draft<CachedState>) => void
32+
updateRecipe: (draft: Draft<CachedState>) => void,
33+
updateProvided?: boolean
3334
) => ThunkAction<PatchCollection, PartialState, any, AnyAction>;
3435

3536
interface PatchCollection {
@@ -43,6 +44,7 @@ interface PatchCollection {
4344
- `endpointName`: a string matching an existing endpoint name
4445
- `args`: an argument matching that used for a previous query call, used to determine which cached dataset needs to be updated
4546
- `updateRecipe`: an Immer `produce` callback that can apply changes to the cached state
47+
- `updateProvided`: a boolean indicating whether the endpoint's provided tags should be re-calculated based on the updated cache. Defaults to `false`.
4648

4749
#### Description
4850

@@ -155,14 +157,16 @@ await dispatch(
155157
const patchQueryData = (
156158
endpointName: string,
157159
args: any
158-
patches: Patch[]
160+
patches: Patch[],
161+
updateProvided?: boolean
159162
) => ThunkAction<void, PartialState, any, AnyAction>;
160163
```
161164

162165
- **Parameters**
163166
- `endpointName`: a string matching an existing endpoint name
164167
- `args`: a cache key, used to determine which cached dataset needs to be updated
165168
- `patches`: an array of patches (or inverse patches) to apply to cached state. These would typically be obtained from the result of dispatching [`updateQueryData`](#updatequerydata)
169+
- `updateProvided`: a boolean indicating whether the endpoint's provided tags should be re-calculated based on the updated cache. Defaults to `false`.
166170

167171
#### Description
168172

@@ -229,42 +233,42 @@ dispatch(api.util.prefetch('getPosts', undefined, { force: true }))
229233
```
230234

231235
### `selectInvalidatedBy`
232-
236+
233237
#### Signature
234-
238+
235239
```ts no-transpile
236-
function selectInvalidatedBy(
237-
state: RootState,
238-
tags: ReadonlyArray<TagDescription<string>>
239-
): Array<{
240-
endpointName: string
241-
originalArgs: any
242-
queryCacheKey: QueryCacheKey
243-
}>
240+
function selectInvalidatedBy(
241+
state: RootState,
242+
tags: ReadonlyArray<TagDescription<string>>
243+
): Array<{
244+
endpointName: string
245+
originalArgs: any
246+
queryCacheKey: QueryCacheKey
247+
}>
244248
```
245-
249+
246250
- **Parameters**
247251
- `state`: the root state
248252
- `tags`: a readonly array of invalidated tags, where the provided `TagDescription` is one of the strings provided to the [`tagTypes`](../createApi.mdx#tagtypes) property of the api. e.g.
249253
- `[TagType]`
250254
- `[{ type: TagType }]`
251255
- `[{ type: TagType, id: number | string }]`
252-
256+
253257
#### Description
254-
258+
255259
A function that can select query parameters to be invalidated.
256-
260+
257261
The function accepts two arguments
258-
- the root state and
259-
- the cache tags to be invalidated.
260-
262+
- the root state and
263+
- the cache tags to be invalidated.
264+
261265
It returns an array that contains
262-
- the endpoint name,
263-
- the original args and
264-
- the queryCacheKey.
265-
266+
- the endpoint name,
267+
- the original args and
268+
- the queryCacheKey.
269+
266270
#### Example
267-
271+
268272
```ts no-transpile
269273
dispatch(api.util.selectInvalidatedBy(state, ['Post']))
270274
dispatch(api.util.selectInvalidatedBy(state, [{ type: 'Post', id: 1 }]))

0 commit comments

Comments
 (0)
Please sign in to comment.