You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/svelte/overview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,4 +71,4 @@ Svelte Query offers useful functions and components that will make managing serv
71
71
Svelte Query offers an API similar to React Query, but there are some key differences to be mindful of.
72
72
73
73
- Many of the functions in Svelte Query return a Svelte store. To access values on these stores reactively, you need to prefix the store with a `$`. You can learn more about Svelte stores [here](https://svelte.dev/tutorial/writable-stores).
74
-
- If your query or mutation depends on variables, you must assign it reactively. You can read more about this [here](./reactivity).
74
+
- If your query or mutation depends on variables, you must use a store for the options. You can read more about this [here](./reactivity).
Copy file name to clipboardExpand all lines: docs/svelte/reactivity.md
+12-9Lines changed: 12 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,12 +3,12 @@ id: reactivity
3
3
title: Reactivity
4
4
---
5
5
6
-
Svelte uses a compiler to build your code which optimises rendering. By default, variables will run once, unless they are referenced in your markup. To make a different variable or function reactive, you need to use [reactive declarations](https://svelte.dev/tutorial/reactive-declarations). This also applies to Svelte Query.
6
+
Svelte uses a compiler to build your code which optimises rendering. By default, variables will run once, unless they are referenced in your markup. To be able to react to changes in options you need to use [stores](https://svelte.dev/tutorial/writable-stores).
7
7
8
8
In the below example, the `refetchInterval` option is set from the variable `intervalMs`, which is edited by the input field. However, as the query is not told it should react to changes in `intervalMs`, `refetchInterval` will not change when the input value changes.
9
9
10
10
```markdown
11
-
<script lang="ts">
11
+
<script>
12
12
import { createQuery } from '@tanstack/svelte-query'
13
13
14
14
let intervalMs = 1000
@@ -25,22 +25,25 @@ In the below example, the `refetchInterval` option is set from the variable `int
25
25
<input bind:value={intervalMs} type="number" />
26
26
```
27
27
28
-
To solve this, you can prefix the query with `$: ` to tell the compiler it should be reactive.
28
+
To solve this, create a store for the options and use it as input for the query. Update the options store when the value changes and the query will react to the change.
29
29
30
30
```markdown
31
-
<script lang="ts">
31
+
<script>
32
32
import { createQuery } from '@tanstack/svelte-query'
0 commit comments