Skip to content

Commit

Permalink
skipPollingIfUnfocused added to polling overview and query options in…
Browse files Browse the repository at this point in the history
… docs
  • Loading branch information
riqts committed Jan 28, 2024
1 parent 5be62b8 commit 8e43f8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/rtk-query/api/created-api/hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ type UseQuery = (

type UseQueryOptions = {
pollingInterval?: number
skipPollingIfUnfocused?: boolean
refetchOnReconnect?: boolean
refetchOnFocus?: boolean
skip?: boolean
Expand Down Expand Up @@ -445,6 +446,7 @@ type UseQuerySubscriptionOptions = {
skip?: boolean
refetchOnMountOrArgChange?: boolean | number
pollingInterval?: number
skipPollingIfUnfocused?: boolean
refetchOnReconnect?: boolean
refetchOnFocus?: boolean
}
Expand Down Expand Up @@ -485,6 +487,7 @@ type UseLazyQuery = (

type UseLazyQueryOptions = {
pollingInterval?: number
skipPollingIfUnfocused?: boolean
refetchOnReconnect?: boolean
refetchOnFocus?: boolean
selectFromResult?: (result: UseQueryStateDefaultResult) => any
Expand Down Expand Up @@ -555,6 +558,7 @@ type UseLazyQuerySubscription = (

type UseLazyQuerySubscriptionOptions = {
pollingInterval?: number
skipPollingIfUnfocused?: boolean
refetchOnReconnect?: boolean
refetchOnFocus?: boolean
}
Expand Down
4 changes: 4 additions & 0 deletions docs/rtk-query/usage/polling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ description: 'RTK Query > Usage > Polling: re-fetching data on a timer'

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:

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.

_Note: `skipPollingIfUnfocused` requires [`setupListeners`](../api/setupListeners.mdx) to have been called_

```tsx no-transpile title="src/Pokemon.tsx" no-transpile
import * as React from 'react'
import { useGetPokemonByNameQuery } from './services/pokemon'
Expand Down

0 comments on commit 8e43f8e

Please sign in to comment.