Skip to content

Commit fd934fa

Browse files
committed
chore(core): update query core & add SvelteStack Discord server
1 parent a39bddd commit fd934fa

File tree

5 files changed

+29
-16
lines changed

5 files changed

+29
-16
lines changed

docs/src/components/Footer.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ export const Footer = props => {
4242
<ul className="mt-4">
4343
<li className="mt-4">
4444
<a
45-
href="https://github.com/TanStack/svelte-query/discussions"
45+
href="https://github.com/SvelteStack/svelte-query/discussions"
4646
className="text-base leading-6 text-gray-500 hover:text-gray-900"
4747
>
4848
Forum & Support
4949
</a>
5050
</li>
5151
<li className="mt-4">
5252
<a
53-
href="https://discord.gg/WrRKjPJ"
53+
href="https://discord.gg/5sK7CPKf"
5454
className="text-base leading-6 text-gray-500 hover:text-gray-900"
5555
>
56-
#TanStack Discord
56+
#SvelteStack Discord
5757
</a>
5858
</li>
5959
<li className="mt-4">
@@ -66,7 +66,7 @@ export const Footer = props => {
6666
</li>
6767
<li className="mt-4">
6868
<a
69-
href="https://github.com/TanStack/svelte-query/releases"
69+
href="https://github.com/SvelteStack/svelte-query/releases"
7070
className="text-base leading-6 text-gray-500 hover:text-gray-900"
7171
>
7272
Releases
@@ -75,12 +75,12 @@ export const Footer = props => {
7575
<li className="mt-4">
7676
<a
7777
className="github-button"
78-
href="https://github.com/TanStack/svelte-query"
78+
href="https://github.com/SvelteStack/svelte-query"
7979
data-color-scheme="no-preference: light; light: light; dark: dark;"
8080
data-icon="octicon-star"
8181
data-size="large"
8282
data-show-count="true"
83-
aria-label="Star TanStack/svelte-query on GitHub"
83+
aria-label="Star SvelteStack/svelte-query on GitHub"
8484
>
8585
Star
8686
</a>
@@ -155,7 +155,7 @@ export const Footer = props => {
155155
</svg>
156156
</a>
157157
<a
158-
href="https://github.com/TanStack"
158+
href="https://github.com/SvelteStack"
159159
className="ml-6 text-gray-400 hover:text-gray-500"
160160
>
161161
<span className="sr-only">GitHub</span>

docs/src/pages/guides/queries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Queries
55

66
## Query Basics
77

8-
A query is a declarative dependency on an asynchronous source of data that is tied to a **unique key**. A query can be used with any Promise based method (including GET and POST methods) to fetch data from a server. If your method modifies data on the server, we recommend using [Mutations](https://svelte-query.tanstack.com/docs/guides/mutations) instead.
8+
A query is a declarative dependency on an asynchronous source of data that is tied to a **unique key**. A query can be used with any Promise based method (including GET and POST methods) to fetch data from a server. If your method modifies data on the server, we recommend using [Mutations](https://svelte-query.vercel.app/guides/mutations) instead.
99

1010
To subscribe to a query in your components or custom hooks, call the `useQuery` hook with at least:
1111

docs/src/pages/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@ const Home = ({ sponsors }) => {
293293
Feeling Chatty?
294294
</h3>
295295
<a
296-
href="https://discord.gg/WrRKjPJ"
296+
href="https://discord.gg/5sK7CPKf"
297297
target="_blank"
298298
className="inline-block bg-gray-800 p-5 text-2xl mx-auto leading-tight font-extrabold tracking-tight text-white mt-12 rounded-full"
299299
>
300-
Join the #TanStack Discord!
300+
Join the #SvelteStack Discord!
301301
</a>
302302
</div>
303303
</div>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@sveltestack/svelte-query",
33
"private": false,
4-
"version": "1.0.7",
4+
"version": "1.0.8",
55
"description": "Hooks for managing, caching and syncing asynchronous and remote data in Svelte",
66
"license": "MIT",
77
"svelte": "svelte/index.js",

src/queryCore/core/queryObserver.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type { Query, QueryState, Action, FetchOptions } from './query'
2121
import type { QueryClient } from './queryClient'
2222
import { focusManager } from './focusManager'
2323
import { Subscribable } from './subscribable'
24+
import { getLogger } from './logger'
2425

2526
type QueryObserverListener<TData, TError> = (
2627
result: QueryObserverResult<TData, TError>
@@ -240,6 +241,9 @@ export class QueryObserver<
240241
this.updateRefetchInterval()
241242
}
242243
}
244+
245+
// Reset previous options after all code related to option changes has run
246+
this.previousOptions = this.options
243247
}
244248

245249
getCurrentResult(): QueryObserverResult<TData, TError> {
@@ -390,6 +394,8 @@ export class QueryObserver<
390394
let isPlaceholderData = false
391395
let data: TData | undefined
392396
let dataUpdatedAt = state.dataUpdatedAt
397+
let error = state.error
398+
let errorUpdatedAt = state.errorUpdatedAt
393399

394400
// Optimistically set status to loading if we will start fetching
395401
if (!this.hasListeners() && this.willFetchOnMount()) {
@@ -421,9 +427,16 @@ export class QueryObserver<
421427
) {
422428
data = this.currentResult.data
423429
} else {
424-
data = this.options.select(state.data)
425-
if (this.options.structuralSharing !== false) {
426-
data = replaceEqualDeep(this.currentResult?.data, data)
430+
try {
431+
data = this.options.select(state.data)
432+
if (this.options.structuralSharing !== false) {
433+
data = replaceEqualDeep(this.currentResult?.data, data)
434+
}
435+
} catch (selectError) {
436+
getLogger().error(selectError)
437+
error = selectError
438+
errorUpdatedAt = Date.now()
439+
status = 'error'
427440
}
428441
}
429442
}
@@ -453,8 +466,8 @@ export class QueryObserver<
453466
...getStatusProps(status),
454467
data,
455468
dataUpdatedAt,
456-
error: state.error,
457-
errorUpdatedAt: state.errorUpdatedAt,
469+
error,
470+
errorUpdatedAt,
458471
failureCount: state.fetchFailureCount,
459472
isFetched: state.dataUpdateCount > 0 || state.errorUpdateCount > 0,
460473
isFetchedAfterMount:

0 commit comments

Comments
 (0)