-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(svelte-query): Update reactivity docs and tests (#5683)
- Loading branch information
1 parent
43dc530
commit 0b2ddb5
Showing
3 changed files
with
114 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
<script lang="ts"> | ||
import { QueryClient } from '@tanstack/query-core' | ||
import { setQueryClientContext } from '../context' | ||
import { createQuery } from '../createQuery' | ||
import type { QueryClient } from '@tanstack/query-core' | ||
import type { CreateQueryOptions } from '../types' | ||
export let options: CreateQueryOptions<any> | ||
export let queryClient: QueryClient | ||
const queryClient = new QueryClient() | ||
setQueryClientContext(queryClient) | ||
const query = createQuery(options) | ||
const query = createQuery(options, queryClient) | ||
</script> | ||
|
||
{#if $query.isPending} | ||
<p>Loading</p> | ||
{:else if $query.isError} | ||
<p>Error</p> | ||
{:else if $query.isSuccess} | ||
<p>Success</p> | ||
{#if Array.isArray($query.data)} | ||
{#each $query.data as item} | ||
<p>{item}</p> | ||
{/each} | ||
{:else} | ||
<p>{$query.data}</p> | ||
{/if} | ||
{/if} | ||
|
||
<ul> | ||
{#each $query.data ?? [] as entry} | ||
<li>id: {entry.id}</li> | ||
{/each} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters