Skip to content

Commit 130ee8d

Browse files
author
ben.durrant
committed
update docs
1 parent dc20b22 commit 130ee8d

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

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

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,12 @@ It returns an array that contains
268268
#### Example
269269

270270
```ts no-transpile
271-
dispatch(api.util.selectInvalidatedBy(state, ['Post']))
272-
dispatch(api.util.selectInvalidatedBy(state, [{ type: 'Post', id: 1 }]))
273-
dispatch(
274-
api.util.selectInvalidatedBy(state, [
275-
{ type: 'Post', id: 1 },
276-
{ type: 'Post', id: 4 },
277-
])
278-
)
271+
const entries = api.util.selectInvalidatedBy(state, ['Post'])
272+
const entries = api.util.selectInvalidatedBy(state, [{ type: 'Post', id: 1 }])
273+
const entries = api.util.selectInvalidatedBy(state, [
274+
{ type: 'Post', id: 1 },
275+
{ type: 'Post', id: 4 },
276+
])
279277
```
280278

281279
### `invalidateTags`
@@ -318,6 +316,39 @@ dispatch(
318316
)
319317
```
320318

319+
### `selectCachedArgsForQuery`
320+
321+
#### Signature
322+
323+
```ts no-transpile
324+
function selectCachedArgsForQuery(
325+
state: RootState,
326+
queryName: QueryName
327+
): Array<QueryArg>
328+
```
329+
330+
- **Parameters**
331+
- `state`: the root state
332+
- `queryName`: a string matching an existing query endpoint name
333+
334+
#### Description
335+
336+
A function that can select arguments for currently cached queries.
337+
338+
The function accepts two arguments
339+
340+
- the root state and
341+
342+
- the name of the query
343+
344+
It returns an array that contains arguments used for each entry.
345+
346+
#### Example
347+
348+
```ts no-transpile
349+
const args = api.util.selectCachedArgsForQuery(state, 'getPosts')
350+
```
351+
321352
### `resetApiState`
322353

323354
#### Signature

docs/rtk-query/api/created-api/overview.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ type Api = {
6161
originalArgs: any
6262
queryCacheKey: string
6363
}>
64+
selectCachedArgsForQuery: (
65+
state: FullState,
66+
endpointName: EndpointName
67+
) => Array<QueryArg>
6468
resetApiState: ActionCreator<ResetAction>
6569
getRunningQueryThunk(
6670
endpointName: EndpointName,

0 commit comments

Comments
 (0)