-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat!(svelte-query): rewrite Svelte adapter to use runes #9694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
ee9346a
b5f5fd4
594e0bf
e3f7484
859d9b7
746b9c5
6e65a4a
540ce06
f0a9ebe
cc5a571
d484552
686db47
e3bba4a
373e24b
d0beb44
bd8737f
e07e895
9f5c7e8
eea078e
968d6a8
62be7d5
c1e67ed
c6d0b92
05f0acd
7049e4b
0c44073
f3fc6a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@tanstack/svelte-query-persist-client': major | ||
'@tanstack/svelte-query-devtools': major | ||
'@tanstack/svelte-query': major | ||
--- | ||
|
||
BREAKING: Migrate to svelte runes (svelte v5+). Please see documentation for migration guide. |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ const config = { | |
kit: { | ||
adapter: adapter(), | ||
}, | ||
compilerOptions: { | ||
runes: true, | ||
}, | ||
} | ||
|
||
export default config |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,29 +3,29 @@ | |||||||||||||||||||||
import { getPostById } from './data' | ||||||||||||||||||||||
import type { Post } from './types' | ||||||||||||||||||||||
export let postId: number | ||||||||||||||||||||||
const { postId }: { postId: number } = $props() | ||||||||||||||||||||||
const post = createQuery<Post>({ | ||||||||||||||||||||||
const post = createQuery<Post>(() => ({ | ||||||||||||||||||||||
queryKey: ['post', postId], | ||||||||||||||||||||||
queryFn: () => getPostById(postId), | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
})) | ||||||||||||||||||||||
Comment on lines
+8
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard query execution when postId is falsy. Without enabled, queryFn may run with undefined postId. Apply: - const post = createQuery<Post>(() => ({
+ const post = createQuery<Post>(() => ({
queryKey: ['post', postId],
queryFn: () => getPostById(postId),
+ enabled: !!postId,
})) 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||
</script> | ||||||||||||||||||||||
|
||||||||||||||||||||||
<div> | ||||||||||||||||||||||
<div> | ||||||||||||||||||||||
<a class="button" href="/"> Back </a> | ||||||||||||||||||||||
</div> | ||||||||||||||||||||||
{#if !postId || $post.isPending} | ||||||||||||||||||||||
{#if !postId || post.isPending} | ||||||||||||||||||||||
<span>Loading...</span> | ||||||||||||||||||||||
{/if} | ||||||||||||||||||||||
{#if $post.error} | ||||||||||||||||||||||
<span>Error: {$post.error.message}</span> | ||||||||||||||||||||||
{#if post.error} | ||||||||||||||||||||||
<span>Error: {post.error.message}</span> | ||||||||||||||||||||||
{/if} | ||||||||||||||||||||||
{#if $post.isSuccess} | ||||||||||||||||||||||
<h1>{$post.data.title}</h1> | ||||||||||||||||||||||
{#if post.isSuccess} | ||||||||||||||||||||||
<h1>{post.data.title}</h1> | ||||||||||||||||||||||
<div> | ||||||||||||||||||||||
<p>{$post.data.body}</p> | ||||||||||||||||||||||
<p>{post.data.body}</p> | ||||||||||||||||||||||
</div> | ||||||||||||||||||||||
<div>{$post.isFetching ? 'Background Updating...' : ' '}</div> | ||||||||||||||||||||||
<div>{post.isFetching ? 'Background Updating...' : ' '}</div> | ||||||||||||||||||||||
{/if} | ||||||||||||||||||||||
</div> |
Uh oh!
There was an error while loading. Please reload this page.