Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@
"label": "Window Focus Refetching",
"to": "framework/solid/guides/window-focus-refetching"
},
{
"label": "Polling",
"to": "framework/solid/guides/polling"
},
{
"label": "Disabling/Pausing Queries",
"to": "framework/solid/guides/disabling-queries"
Expand Down Expand Up @@ -536,6 +540,10 @@
"label": "Window Focus Refetching",
"to": "framework/vue/guides/window-focus-refetching"
},
{
"label": "Polling",
"to": "framework/vue/guides/polling"
},
{
"label": "Disabling/Pausing Queries",
"to": "framework/vue/guides/disabling-queries"
Expand Down
68 changes: 68 additions & 0 deletions docs/framework/solid/guides/polling.md
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: if an example stays the same, you don’t need to override it - you can just leave it as-is.

I’d also appreciate it if you’d just amend the other open PR instead of adding a new, dependent PR.

So I’m closing this, but please move it over to #10330

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
id: polling
title: Polling
ref: docs/framework/react/guides/polling.md
replace: { '@tanstack/react-query': '@tanstack/solid-query' }
---

[//]: # 'Example1'

```tsx
useQuery(() => ({
queryKey: ['prices'],
queryFn: fetchPrices,
refetchInterval: 5_000,
}))
```

[//]: # 'Example1'
[//]: # 'Example2'

```tsx
useQuery(() => ({
queryKey: ['job', jobId],
queryFn: () => fetchJobStatus(jobId),
refetchInterval: (query) => {
if (query.state.data?.status === 'complete') return false
return 2_000
},
}))
```

[//]: # 'Example2'
[//]: # 'Example3'

```tsx
useQuery(() => ({
queryKey: ['portfolio'],
queryFn: fetchPortfolio,
refetchInterval: 30_000,
refetchIntervalInBackground: true,
}))
```

[//]: # 'Example3'
[//]: # 'Example6'

```tsx
useQuery(() => ({
queryKey: ['prices', tokenAddress],
queryFn: () => fetchPrice(tokenAddress),
refetchInterval: 15_000,
enabled: !!tokenAddress && !isPaused,
}))
```

[//]: # 'Example6'
[//]: # 'Example7'

```tsx
useQuery(() => ({
queryKey: ['chainStatus'],
queryFn: fetchChainStatus,
refetchInterval: 10_000,
networkMode: 'always',
}))
```

[//]: # 'Example7'
27 changes: 27 additions & 0 deletions docs/framework/vue/guides/polling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
id: polling
title: Polling
ref: docs/framework/react/guides/polling.md
replace: { '@tanstack/react-query': '@tanstack/vue-query' }
---

[//]: # 'Example4'

```ts
import { VueQueryPlugin } from '@tanstack/vue-query'
import type { VueQueryPluginOptions } from '@tanstack/vue-query'

const vueQueryPluginOptions: VueQueryPluginOptions = {
queryClientConfig: {
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
refetchInterval: 60_000,
},
},
},
}
app.use(VueQueryPlugin, vueQueryPluginOptions)
```

[//]: # 'Example4'
Loading