Skip to content

Commit 8e43f8e

Browse files
committed
skipPollingIfUnfocused added to polling overview and query options in docs
1 parent 5be62b8 commit 8e43f8e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ type UseQuery = (
251251

252252
type UseQueryOptions = {
253253
pollingInterval?: number
254+
skipPollingIfUnfocused?: boolean
254255
refetchOnReconnect?: boolean
255256
refetchOnFocus?: boolean
256257
skip?: boolean
@@ -445,6 +446,7 @@ type UseQuerySubscriptionOptions = {
445446
skip?: boolean
446447
refetchOnMountOrArgChange?: boolean | number
447448
pollingInterval?: number
449+
skipPollingIfUnfocused?: boolean
448450
refetchOnReconnect?: boolean
449451
refetchOnFocus?: boolean
450452
}
@@ -485,6 +487,7 @@ type UseLazyQuery = (
485487

486488
type UseLazyQueryOptions = {
487489
pollingInterval?: number
490+
skipPollingIfUnfocused?: boolean
488491
refetchOnReconnect?: boolean
489492
refetchOnFocus?: boolean
490493
selectFromResult?: (result: UseQueryStateDefaultResult) => any
@@ -555,6 +558,7 @@ type UseLazyQuerySubscription = (
555558

556559
type UseLazyQuerySubscriptionOptions = {
557560
pollingInterval?: number
561+
skipPollingIfUnfocused?: boolean
558562
refetchOnReconnect?: boolean
559563
refetchOnFocus?: boolean
560564
}

docs/rtk-query/usage/polling.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ description: 'RTK Query > Usage > Polling: re-fetching data on a timer'
1414

1515
Polling gives you the ability to have a 'real-time' effect by causing a query to run at a specified interval. To enable polling for a query, pass a `pollingInterval` to the `useQuery` hook or action creator with an interval in milliseconds:
1616

17+
Polling additionally has the ability to skip sending requests while the window is out of focus. To enable this behavior, pass `skipPollingIfUnfocused: true` to the `useQuery` hook or action creator.
18+
19+
_Note: `skipPollingIfUnfocused` requires [`setupListeners`](../api/setupListeners.mdx) to have been called_
20+
1721
```tsx no-transpile title="src/Pokemon.tsx" no-transpile
1822
import * as React from 'react'
1923
import { useGetPokemonByNameQuery } from './services/pokemon'

0 commit comments

Comments
 (0)