@tanstack/svelte-query 6.3.1 → 6.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/containers.svelte.d.ts +16 -0
- package/dist/containers.svelte.d.ts.map +1 -1
- package/dist/containers.svelte.js +26 -0
- package/dist/context.d.ts +10 -6
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +10 -6
- package/dist/createBaseQuery.svelte.d.ts +1 -0
- package/dist/createBaseQuery.svelte.d.ts.map +1 -1
- package/dist/createBaseQuery.svelte.js +6 -0
- package/dist/createInfiniteQuery.d.ts +6 -11
- package/dist/createInfiniteQuery.d.ts.map +1 -1
- package/dist/createMutation.svelte.d.ts +2 -8
- package/dist/createMutation.svelte.d.ts.map +1 -1
- package/dist/createMutation.svelte.js +2 -8
- package/dist/createQueries.svelte.d.ts +0 -3
- package/dist/createQueries.svelte.d.ts.map +1 -1
- package/dist/createQueries.svelte.js +4 -3
- package/dist/createQuery.d.ts +6 -12
- package/dist/createQuery.d.ts.map +1 -1
- package/dist/infiniteQueryOptions.d.ts +10 -6
- package/dist/infiniteQueryOptions.d.ts.map +1 -1
- package/dist/mutationOptions.d.ts +2 -6
- package/dist/mutationOptions.d.ts.map +1 -1
- package/dist/queryOptions.d.ts +10 -6
- package/dist/queryOptions.d.ts.map +1 -1
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/useHydrate.d.ts +0 -2
- package/dist/useHydrate.d.ts.map +1 -1
- package/dist/useHydrate.js +0 -2
- package/dist/useIsFetching.svelte.d.ts +0 -3
- package/dist/useIsFetching.svelte.d.ts.map +1 -1
- package/dist/useIsFetching.svelte.js +0 -3
- package/dist/useIsMutating.svelte.d.ts +0 -2
- package/dist/useIsMutating.svelte.d.ts.map +1 -1
- package/dist/useIsMutating.svelte.js +0 -2
- package/dist/useIsRestoring.d.ts +0 -1
- package/dist/useIsRestoring.d.ts.map +1 -1
- package/dist/useIsRestoring.js +0 -1
- package/dist/useMutationState.svelte.d.ts +0 -4
- package/dist/useMutationState.svelte.d.ts.map +1 -1
- package/dist/useMutationState.svelte.js +7 -4
- package/dist/useQueryClient.d.ts +2 -2
- package/dist/useQueryClient.js +2 -2
- package/dist/utils.svelte.d.ts +8 -0
- package/dist/utils.svelte.d.ts.map +1 -1
- package/dist/utils.svelte.js +13 -0
- package/package.json +4 -4
- package/src/containers.svelte.ts +35 -1
- package/src/context.ts +10 -6
- package/src/createBaseQuery.svelte.ts +6 -0
- package/src/createInfiniteQuery.ts +6 -11
- package/src/createMutation.svelte.ts +2 -8
- package/src/createQueries.svelte.ts +4 -3
- package/src/createQuery.ts +6 -12
- package/src/infiniteQueryOptions.ts +10 -6
- package/src/mutationOptions.ts +2 -6
- package/src/queryOptions.ts +12 -7
- package/src/types.ts +37 -0
- package/src/useHydrate.ts +0 -2
- package/src/useIsFetching.svelte.ts +0 -3
- package/src/useIsMutating.svelte.ts +0 -2
- package/src/useIsRestoring.ts +0 -1
- package/src/useMutationState.svelte.ts +7 -4
- package/src/useQueryClient.ts +2 -2
- package/src/utils.svelte.ts +13 -0
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
type VoidFn = () => void;
|
|
2
2
|
type Subscriber = (update: VoidFn) => void | VoidFn;
|
|
3
|
+
/**
|
|
4
|
+
* An object holding a value in its `current` property, e.g. a reactive value backed by `$state`.
|
|
5
|
+
*/
|
|
3
6
|
export type Box<T> = {
|
|
7
|
+
/**
|
|
8
|
+
* The held value.
|
|
9
|
+
*/
|
|
4
10
|
current: T;
|
|
5
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* A {@link Box} whose `current` value is computed on each read, and that notifies the reactive
|
|
14
|
+
* contexts reading it through the given subscriber.
|
|
15
|
+
*/
|
|
6
16
|
export declare class ReactiveValue<T> implements Box<T> {
|
|
7
17
|
#private;
|
|
8
18
|
constructor(fn: () => T, onSubscribe: Subscriber);
|
|
19
|
+
/**
|
|
20
|
+
* Subscribes the reactive context reading it, then computes the value.
|
|
21
|
+
* @returns The value returned by the compute function.
|
|
22
|
+
*/
|
|
9
23
|
get current(): T;
|
|
10
24
|
}
|
|
11
25
|
/**
|
|
@@ -13,6 +27,8 @@ export declare class ReactiveValue<T> implements Box<T> {
|
|
|
13
27
|
* are the same as in the original object. Does not mutate the original object. Provides an `update`
|
|
14
28
|
* function that _can_ (but does not have to be) be used to replace all of the object's top-level keys
|
|
15
29
|
* with the values of the new object, while maintaining the original root object's reference.
|
|
30
|
+
* @param init - The object or array whose top-level keys become the initial fields.
|
|
31
|
+
* @returns A tuple of the reactive object and the `update` function.
|
|
16
32
|
*/
|
|
17
33
|
export declare function createRawRef<T extends {} | Array<unknown>>(init: T): [T, (newValue: T) => void];
|
|
18
34
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containers.svelte.d.ts","sourceRoot":"","sources":["../src/containers.svelte.ts"],"names":[],"mappings":"AAEA,KAAK,MAAM,GAAG,MAAM,IAAI,CAAA;AACxB,KAAK,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,CAAA;AAEnD,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI;
|
|
1
|
+
{"version":3,"file":"containers.svelte.d.ts","sourceRoot":"","sources":["../src/containers.svelte.ts"],"names":[],"mappings":"AAEA,KAAK,MAAM,GAAG,MAAM,IAAI,CAAA;AACxB,KAAK,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,CAAA;AAEnD;;GAEG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI;IACnB;;OAEG;IACH,OAAO,EAAE,CAAC,CAAA;CACX,CAAA;AAED;;;GAGG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,GAAG,CAAC,CAAC,CAAC;;gBAIjC,EAAE,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU;IAKhD;;;OAGG;IACH,IAAI,OAAO,MAGV;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,EACxD,IAAI,EAAE,CAAC,GACN,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC,CA8G5B"}
|
|
@@ -11,6 +11,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _ReactiveValue_fn, _ReactiveValue_subscribe;
|
|
13
13
|
import { SvelteSet, createSubscriber } from 'svelte/reactivity';
|
|
14
|
+
/**
|
|
15
|
+
* A {@link Box} whose `current` value is computed on each read, and that notifies the reactive
|
|
16
|
+
* contexts reading it through the given subscriber.
|
|
17
|
+
*/
|
|
14
18
|
export class ReactiveValue {
|
|
15
19
|
constructor(fn, onSubscribe) {
|
|
16
20
|
_ReactiveValue_fn.set(this, void 0);
|
|
@@ -18,6 +22,10 @@ export class ReactiveValue {
|
|
|
18
22
|
__classPrivateFieldSet(this, _ReactiveValue_fn, fn, "f");
|
|
19
23
|
__classPrivateFieldSet(this, _ReactiveValue_subscribe, createSubscriber((update) => onSubscribe(update)), "f");
|
|
20
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Subscribes the reactive context reading it, then computes the value.
|
|
27
|
+
* @returns The value returned by the compute function.
|
|
28
|
+
*/
|
|
21
29
|
get current() {
|
|
22
30
|
__classPrivateFieldGet(this, _ReactiveValue_subscribe, "f").call(this);
|
|
23
31
|
return __classPrivateFieldGet(this, _ReactiveValue_fn, "f").call(this);
|
|
@@ -29,6 +37,8 @@ _ReactiveValue_fn = new WeakMap(), _ReactiveValue_subscribe = new WeakMap();
|
|
|
29
37
|
* are the same as in the original object. Does not mutate the original object. Provides an `update`
|
|
30
38
|
* function that _can_ (but does not have to be) be used to replace all of the object's top-level keys
|
|
31
39
|
* with the values of the new object, while maintaining the original root object's reference.
|
|
40
|
+
* @param init - The object or array whose top-level keys become the initial fields.
|
|
41
|
+
* @returns A tuple of the reactive object and the `update` function.
|
|
32
42
|
*/
|
|
33
43
|
export function createRawRef(init) {
|
|
34
44
|
const refObj = (Array.isArray(init) ? [] : {});
|
|
@@ -98,6 +108,11 @@ export function createRawRef(init) {
|
|
|
98
108
|
return false;
|
|
99
109
|
},
|
|
100
110
|
});
|
|
111
|
+
/**
|
|
112
|
+
* Replaces the top-level keys of the reactive object with those of `newValue`, removing keys that
|
|
113
|
+
* `newValue` doesn't have, while keeping the object's reference.
|
|
114
|
+
* @param newValue - The object or array to take the new keys and values from.
|
|
115
|
+
*/
|
|
101
116
|
function update(newValue) {
|
|
102
117
|
const existingKeys = Object.keys(out);
|
|
103
118
|
const newKeys = Object.keys(newValue);
|
|
@@ -132,11 +147,22 @@ export function createRawRef(init) {
|
|
|
132
147
|
return [out, update];
|
|
133
148
|
}
|
|
134
149
|
const lazyBrand = Symbol('LazyValue');
|
|
150
|
+
/**
|
|
151
|
+
* Marks a function as a lazy value, so that reading the property it is stored in calls it instead of
|
|
152
|
+
* returning the function.
|
|
153
|
+
* @param fn - The function that returns the value.
|
|
154
|
+
* @returns The same function, marked as lazy.
|
|
155
|
+
*/
|
|
135
156
|
function brand(fn) {
|
|
136
157
|
// @ts-expect-error
|
|
137
158
|
fn[lazyBrand] = true;
|
|
138
159
|
return fn;
|
|
139
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Checks whether a function was marked as a lazy value with {@link brand}.
|
|
163
|
+
* @param fn - The function to check.
|
|
164
|
+
* @returns `true` if the function is marked as lazy.
|
|
165
|
+
*/
|
|
140
166
|
function isBranded(fn) {
|
|
141
167
|
return Boolean(fn[lazyBrand]);
|
|
142
168
|
}
|
package/dist/context.d.ts
CHANGED
|
@@ -3,18 +3,15 @@ import type { Box } from './containers.svelte';
|
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves the `QueryClient` set on Svelte's context by `QueryClientProvider` (or by
|
|
5
5
|
* {@link setQueryClientContext} directly). This is what {@link useQueryClient} calls internally.
|
|
6
|
-
*
|
|
7
|
-
* @throws If no `QueryClient` was found in context.
|
|
8
6
|
* @returns The `QueryClient` set on context, whether by `QueryClientProvider` or {@link setQueryClientContext}.
|
|
7
|
+
* @throws {Error} If no `QueryClient` was found in context.
|
|
9
8
|
*/
|
|
10
9
|
export declare const getQueryClientContext: () => QueryClient;
|
|
11
10
|
/**
|
|
12
11
|
* Sets a `QueryClient` on Svelte's context, so it can be read with {@link getQueryClientContext} (or
|
|
13
12
|
* {@link useQueryClient}) from any descendant component. `QueryClientProvider` wraps this — use it directly
|
|
14
13
|
* only if you need to set the client from your own component instead.
|
|
15
|
-
*
|
|
16
14
|
* @param client - The `QueryClient` to make available to descendant components.
|
|
17
|
-
*
|
|
18
15
|
* @example
|
|
19
16
|
* ```svelte
|
|
20
17
|
* <script lang="ts">
|
|
@@ -29,8 +26,15 @@ export declare const getQueryClientContext: () => QueryClient;
|
|
|
29
26
|
* ```
|
|
30
27
|
*/
|
|
31
28
|
export declare const setQueryClientContext: (client: QueryClient) => void;
|
|
32
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves a `isRestoring` from Svelte's context.
|
|
31
|
+
* @returns The `isRestoring` box set on context, or a box holding `false` if none was set or the
|
|
32
|
+
* context is unavailable.
|
|
33
|
+
*/
|
|
33
34
|
export declare const getIsRestoringContext: () => Box<boolean>;
|
|
34
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Sets a `isRestoring` on Svelte's context.
|
|
37
|
+
* @param isRestoring - The box holding whether the cache is being restored, e.g. by a persister.
|
|
38
|
+
*/
|
|
35
39
|
export declare const setIsRestoringContext: (isRestoring: Box<boolean>) => void;
|
|
36
40
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAI9C
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAI9C;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAO,WASxC,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,WAAW,KAAG,IAE3D,CAAA;AAID;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAO,GAAG,CAAC,OAAO,CASnD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,aAAa,GAAG,CAAC,OAAO,CAAC,KAAG,IAEjE,CAAA"}
|
package/dist/context.js
CHANGED
|
@@ -3,9 +3,8 @@ const _contextKey = Symbol('QueryClient');
|
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves the `QueryClient` set on Svelte's context by `QueryClientProvider` (or by
|
|
5
5
|
* {@link setQueryClientContext} directly). This is what {@link useQueryClient} calls internally.
|
|
6
|
-
*
|
|
7
|
-
* @throws If no `QueryClient` was found in context.
|
|
8
6
|
* @returns The `QueryClient` set on context, whether by `QueryClientProvider` or {@link setQueryClientContext}.
|
|
7
|
+
* @throws {Error} If no `QueryClient` was found in context.
|
|
9
8
|
*/
|
|
10
9
|
export const getQueryClientContext = () => {
|
|
11
10
|
const client = getContext(_contextKey);
|
|
@@ -18,9 +17,7 @@ export const getQueryClientContext = () => {
|
|
|
18
17
|
* Sets a `QueryClient` on Svelte's context, so it can be read with {@link getQueryClientContext} (or
|
|
19
18
|
* {@link useQueryClient}) from any descendant component. `QueryClientProvider` wraps this — use it directly
|
|
20
19
|
* only if you need to set the client from your own component instead.
|
|
21
|
-
*
|
|
22
20
|
* @param client - The `QueryClient` to make available to descendant components.
|
|
23
|
-
*
|
|
24
21
|
* @example
|
|
25
22
|
* ```svelte
|
|
26
23
|
* <script lang="ts">
|
|
@@ -38,7 +35,11 @@ export const setQueryClientContext = (client) => {
|
|
|
38
35
|
setContext(_contextKey, client);
|
|
39
36
|
};
|
|
40
37
|
const _isRestoringContextKey = Symbol('isRestoring');
|
|
41
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves a `isRestoring` from Svelte's context.
|
|
40
|
+
* @returns The `isRestoring` box set on context, or a box holding `false` if none was set or the
|
|
41
|
+
* context is unavailable.
|
|
42
|
+
*/
|
|
42
43
|
export const getIsRestoringContext = () => {
|
|
43
44
|
try {
|
|
44
45
|
const isRestoring = getContext(_isRestoringContextKey);
|
|
@@ -48,7 +49,10 @@ export const getIsRestoringContext = () => {
|
|
|
48
49
|
return { current: false };
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Sets a `isRestoring` on Svelte's context.
|
|
54
|
+
* @param isRestoring - The box holding whether the cache is being restored, e.g. by a persister.
|
|
55
|
+
*/
|
|
52
56
|
export const setIsRestoringContext = (isRestoring) => {
|
|
53
57
|
setContext(_isRestoringContextKey, isRestoring);
|
|
54
58
|
};
|
|
@@ -5,6 +5,7 @@ import type { Accessor, CreateBaseQueryOptions, CreateBaseQueryResult } from './
|
|
|
5
5
|
* @param options - A function that returns query options
|
|
6
6
|
* @param Observer - The observer from query-core
|
|
7
7
|
* @param queryClient - Custom query client which overrides provider
|
|
8
|
+
* @returns The reactive query result.
|
|
8
9
|
*/
|
|
9
10
|
export declare function createBaseQuery<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(options: Accessor<CreateBaseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>>, Observer: typeof QueryObserver, queryClient?: Accessor<QueryClient>): CreateBaseQueryResult<TData, TError>;
|
|
10
11
|
//# sourceMappingURL=createBaseQuery.svelte.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBaseQuery.svelte.d.ts","sourceRoot":"","sources":["../src/createBaseQuery.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAChF,OAAO,KAAK,EACV,QAAQ,EACR,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,YAAY,CAAA;AAEnB
|
|
1
|
+
{"version":3,"file":"createBaseQuery.svelte.d.ts","sourceRoot":"","sources":["../src/createBaseQuery.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAChF,OAAO,KAAK,EACV,QAAQ,EACR,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,YAAY,CAAA;AAEnB;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EACZ,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,SAAS,QAAQ,EAE1B,OAAO,EAAE,QAAQ,CACf,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,CAAC,CAC3E,EACD,QAAQ,EAAE,OAAO,aAAa,EAC9B,WAAW,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAClC,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,CAuGtC"}
|
|
@@ -8,6 +8,7 @@ import { watchChanges } from './utils.svelte.js';
|
|
|
8
8
|
* @param options - A function that returns query options
|
|
9
9
|
* @param Observer - The observer from query-core
|
|
10
10
|
* @param queryClient - Custom query client which overrides provider
|
|
11
|
+
* @returns The reactive query result.
|
|
11
12
|
*/
|
|
12
13
|
export function createBaseQuery(options, Observer, queryClient) {
|
|
13
14
|
/** Load query client */
|
|
@@ -24,6 +25,11 @@ export function createBaseQuery(options, Observer, queryClient) {
|
|
|
24
25
|
watchChanges(() => client, 'pre', () => {
|
|
25
26
|
observer = new Observer(client, resolvedOptions);
|
|
26
27
|
});
|
|
28
|
+
/**
|
|
29
|
+
* Computes the observer's current result for the resolved options, tracking property access unless
|
|
30
|
+
* `notifyOnChangeProps` is set.
|
|
31
|
+
* @returns The current query result.
|
|
32
|
+
*/
|
|
27
33
|
function createResult() {
|
|
28
34
|
const result = observer.getOptimisticResult(resolvedOptions);
|
|
29
35
|
return !resolvedOptions.notifyOnChangeProps
|
|
@@ -6,15 +6,14 @@ import type { DefinedInitialDataInfiniteOptions, UndefinedInitialDataInfiniteOpt
|
|
|
6
6
|
* `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.
|
|
7
7
|
*
|
|
8
8
|
* This overload is selected when `initialData` is known to be defined.
|
|
9
|
-
*
|
|
10
|
-
* @see {@link infiniteQueryOptions} to share these options between `createInfiniteQuery` and imperative APIs
|
|
11
|
-
* like `queryClient.infiniteQuery`.
|
|
12
9
|
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to
|
|
13
10
|
* `createInfiniteQuery`, with `initialData` set, wrapped in an {@link Accessor} so options can be reactive.
|
|
14
11
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
15
12
|
* be used.
|
|
16
13
|
* @returns The current query result, plus `fetchNextPage`/`fetchPreviousPage`/`hasNextPage`/`hasPreviousPage`
|
|
17
14
|
* to page through the query.
|
|
15
|
+
* @see {@link infiniteQueryOptions} to share these options between `createInfiniteQuery` and imperative APIs
|
|
16
|
+
* like `queryClient.infiniteQuery`.
|
|
18
17
|
*/
|
|
19
18
|
export declare function createInfiniteQuery<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: Accessor<DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>>, queryClient?: Accessor<QueryClient>): DefinedCreateInfiniteQueryResult<TData, TError>;
|
|
20
19
|
/**
|
|
@@ -22,30 +21,27 @@ export declare function createInfiniteQuery<TQueryFnData = unknown, TError = Def
|
|
|
22
21
|
* `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.
|
|
23
22
|
*
|
|
24
23
|
* This overload is selected when `initialData` is omitted or may be `undefined`.
|
|
25
|
-
*
|
|
26
|
-
* @see {@link infiniteQueryOptions} to share these options between `createInfiniteQuery` and imperative APIs
|
|
27
|
-
* like `queryClient.infiniteQuery`.
|
|
28
24
|
* @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to
|
|
29
25
|
* `createInfiniteQuery`, wrapped in an {@link Accessor} so options can be reactive.
|
|
30
26
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
31
27
|
* be used.
|
|
32
28
|
* @returns The current query result, plus `fetchNextPage`/`fetchPreviousPage`/`hasNextPage`/`hasPreviousPage`
|
|
33
29
|
* to page through the query.
|
|
30
|
+
* @see {@link infiniteQueryOptions} to share these options between `createInfiniteQuery` and imperative APIs
|
|
31
|
+
* like `queryClient.infiniteQuery`.
|
|
34
32
|
*/
|
|
35
33
|
export declare function createInfiniteQuery<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: Accessor<UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>>, queryClient?: Accessor<QueryClient>): CreateInfiniteQueryResult<TData, TError>;
|
|
36
34
|
/**
|
|
37
35
|
* The options for `createInfiniteQuery` are identical to `createQuery`, with the addition of
|
|
38
36
|
* `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.
|
|
39
|
-
*
|
|
40
|
-
* @see {@link infiniteQueryOptions} to share these options between `createInfiniteQuery` and imperative APIs
|
|
41
|
-
* like `queryClient.infiniteQuery`.
|
|
42
37
|
* @param options - The {@link CreateInfiniteQueryOptions} to use — everything you can pass to
|
|
43
38
|
* `createInfiniteQuery`, wrapped in an {@link Accessor} so options can be reactive.
|
|
44
39
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
45
40
|
* be used.
|
|
46
41
|
* @returns The current query result, plus `fetchNextPage`/`fetchPreviousPage`/`hasNextPage`/`hasPreviousPage`
|
|
47
42
|
* to page through the query.
|
|
48
|
-
*
|
|
43
|
+
* @see {@link infiniteQueryOptions} to share these options between `createInfiniteQuery` and imperative APIs
|
|
44
|
+
* like `queryClient.infiniteQuery`.
|
|
49
45
|
* @example
|
|
50
46
|
* Fetching the next page from a "Load More" button click:
|
|
51
47
|
* ```svelte
|
|
@@ -84,7 +80,6 @@ export declare function createInfiniteQuery<TQueryFnData = unknown, TError = Def
|
|
|
84
80
|
* </button>
|
|
85
81
|
* {/if}
|
|
86
82
|
* ```
|
|
87
|
-
*
|
|
88
83
|
* @example
|
|
89
84
|
* Fetching the next page automatically as the user scrolls, using an `IntersectionObserver` on a
|
|
90
85
|
* sentinel element after the list:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInfiniteQuery.d.ts","sourceRoot":"","sources":["../src/createInfiniteQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,QAAQ,EAET,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,QAAQ,EACR,0BAA0B,EAC1B,yBAAyB,EACzB,gCAAgC,EACjC,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EACV,iCAAiC,EACjC,mCAAmC,EACpC,MAAM,2BAA2B,CAAA;AAElC
|
|
1
|
+
{"version":3,"file":"createInfiniteQuery.d.ts","sourceRoot":"","sources":["../src/createInfiniteQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,QAAQ,EAET,MAAM,sBAAsB,CAAA;AAC7B,OAAO,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EACrC,UAAU,GAAG,OAAO,EAEpB,OAAO,EAAE,QAAQ,CACf,0BAA0B,CACxB,YAAY,EACZ,MAAM,EACN,KAAK,EACL,SAAS,EACT,UAAU,CACX,CACF,EACD,WAAW,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAClC,yBAAyB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA"}
|
|
@@ -3,9 +3,6 @@ import type { DefaultError, QueryClient } from '@tanstack/query-core';
|
|
|
3
3
|
/**
|
|
4
4
|
* Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
|
|
5
5
|
* `createMutation` is the function for that.
|
|
6
|
-
*
|
|
7
|
-
* @see {@link mutationOptions} to share these options across multiple `createMutation` call sites, or to look
|
|
8
|
-
* the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).
|
|
9
6
|
* @param options - The {@link CreateMutationOptions} to use, wrapped in an {@link Accessor} so options can be
|
|
10
7
|
* reactive.
|
|
11
8
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
@@ -14,7 +11,8 @@ import type { DefaultError, QueryClient } from '@tanstack/query-core';
|
|
|
14
11
|
* argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared
|
|
15
12
|
* mutation definition. If you make multiple requests, `onSuccess` will fire only after the latest call you've
|
|
16
13
|
* made.
|
|
17
|
-
*
|
|
14
|
+
* @see {@link mutationOptions} to share these options across multiple `createMutation` call sites, or to look
|
|
15
|
+
* the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).
|
|
18
16
|
* @example
|
|
19
17
|
* ```svelte
|
|
20
18
|
* <script lang="ts">
|
|
@@ -38,7 +36,6 @@ import type { DefaultError, QueryClient } from '@tanstack/query-core';
|
|
|
38
36
|
* Add
|
|
39
37
|
* </button>
|
|
40
38
|
* ```
|
|
41
|
-
*
|
|
42
39
|
* @example
|
|
43
40
|
* Rendering the mutation's own state, rather than just firing it off:
|
|
44
41
|
* ```svelte
|
|
@@ -62,7 +59,6 @@ import type { DefaultError, QueryClient } from '@tanstack/query-core';
|
|
|
62
59
|
* <button onclick={() => addMutation.mutate('Item')}>Add</button>
|
|
63
60
|
* {/if}
|
|
64
61
|
* ```
|
|
65
|
-
*
|
|
66
62
|
* @example
|
|
67
63
|
* Optimistic update via `onMutate`, rolling back on `onError`:
|
|
68
64
|
* ```svelte
|
|
@@ -96,7 +92,6 @@ import type { DefaultError, QueryClient } from '@tanstack/query-core';
|
|
|
96
92
|
*
|
|
97
93
|
* <button onclick={() => addMutation.mutate('Item')}>Add</button>
|
|
98
94
|
* ```
|
|
99
|
-
*
|
|
100
95
|
* @example
|
|
101
96
|
* Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a
|
|
102
97
|
* promise per call instead, so you can wait for all of them when they succeed:
|
|
@@ -124,7 +119,6 @@ import type { DefaultError, QueryClient } from '@tanstack/query-core';
|
|
|
124
119
|
* Add all
|
|
125
120
|
* </button>
|
|
126
121
|
* ```
|
|
127
|
-
*
|
|
128
122
|
* @example
|
|
129
123
|
* If some of the mutations above can fail independently of the others, and you want to know which ones
|
|
130
124
|
* did — rather than losing that information the moment the first one rejects — swap `Promise.all` for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMutation.svelte.d.ts","sourceRoot":"","sources":["../src/createMutation.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,QAAQ,EAER,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAErE
|
|
1
|
+
{"version":3,"file":"createMutation.svelte.d.ts","sourceRoot":"","sources":["../src/createMutation.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,QAAQ,EAER,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuJG;AACH,wBAAgB,cAAc,CAC5B,KAAK,GAAG,OAAO,EACf,MAAM,GAAG,YAAY,EACrB,UAAU,GAAG,IAAI,EACjB,QAAQ,GAAG,OAAO,EAElB,OAAO,EAAE,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,EAC7E,WAAW,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAClC,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAiE3D"}
|
|
@@ -4,9 +4,6 @@ import { watchChanges } from './utils.svelte.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
|
|
6
6
|
* `createMutation` is the function for that.
|
|
7
|
-
*
|
|
8
|
-
* @see {@link mutationOptions} to share these options across multiple `createMutation` call sites, or to look
|
|
9
|
-
* the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).
|
|
10
7
|
* @param options - The {@link CreateMutationOptions} to use, wrapped in an {@link Accessor} so options can be
|
|
11
8
|
* reactive.
|
|
12
9
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
@@ -15,7 +12,8 @@ import { watchChanges } from './utils.svelte.js';
|
|
|
15
12
|
* argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared
|
|
16
13
|
* mutation definition. If you make multiple requests, `onSuccess` will fire only after the latest call you've
|
|
17
14
|
* made.
|
|
18
|
-
*
|
|
15
|
+
* @see {@link mutationOptions} to share these options across multiple `createMutation` call sites, or to look
|
|
16
|
+
* the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).
|
|
19
17
|
* @example
|
|
20
18
|
* ```svelte
|
|
21
19
|
* <script lang="ts">
|
|
@@ -39,7 +37,6 @@ import { watchChanges } from './utils.svelte.js';
|
|
|
39
37
|
* Add
|
|
40
38
|
* </button>
|
|
41
39
|
* ```
|
|
42
|
-
*
|
|
43
40
|
* @example
|
|
44
41
|
* Rendering the mutation's own state, rather than just firing it off:
|
|
45
42
|
* ```svelte
|
|
@@ -63,7 +60,6 @@ import { watchChanges } from './utils.svelte.js';
|
|
|
63
60
|
* <button onclick={() => addMutation.mutate('Item')}>Add</button>
|
|
64
61
|
* {/if}
|
|
65
62
|
* ```
|
|
66
|
-
*
|
|
67
63
|
* @example
|
|
68
64
|
* Optimistic update via `onMutate`, rolling back on `onError`:
|
|
69
65
|
* ```svelte
|
|
@@ -97,7 +93,6 @@ import { watchChanges } from './utils.svelte.js';
|
|
|
97
93
|
*
|
|
98
94
|
* <button onclick={() => addMutation.mutate('Item')}>Add</button>
|
|
99
95
|
* ```
|
|
100
|
-
*
|
|
101
96
|
* @example
|
|
102
97
|
* Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a
|
|
103
98
|
* promise per call instead, so you can wait for all of them when they succeed:
|
|
@@ -125,7 +120,6 @@ import { watchChanges } from './utils.svelte.js';
|
|
|
125
120
|
* Add all
|
|
126
121
|
* </button>
|
|
127
122
|
* ```
|
|
128
|
-
*
|
|
129
123
|
* @example
|
|
130
124
|
* If some of the mutations above can fail independently of the others, and you want to know which ones
|
|
131
125
|
* did — rather than losing that information the moment the first one rejects — swap `Promise.all` for
|
|
@@ -66,14 +66,12 @@ export type QueriesResults<T extends Array<any>, TResults extends Array<any> = [
|
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
68
|
* The `createQueries` function can be used to fetch a variable number of queries.
|
|
69
|
-
*
|
|
70
69
|
* @param createQueriesOptions - The `queries` array to run, and an optional `combine` function, wrapped in an
|
|
71
70
|
* {@link Accessor} so options can be reactive.
|
|
72
71
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context
|
|
73
72
|
* will be used.
|
|
74
73
|
* @returns An array with one result per query, in the same order as `queries` — or, if `combine` is provided,
|
|
75
74
|
* whatever `combine` returns.
|
|
76
|
-
*
|
|
77
75
|
* @example
|
|
78
76
|
* ```svelte
|
|
79
77
|
* <script lang="ts">
|
|
@@ -102,7 +100,6 @@ export type QueriesResults<T extends Array<any>, TResults extends Array<any> = [
|
|
|
102
100
|
* {/each}
|
|
103
101
|
* </ul>
|
|
104
102
|
* ```
|
|
105
|
-
*
|
|
106
103
|
* @example
|
|
107
104
|
* Combining results into a single value:
|
|
108
105
|
* ```svelte
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createQueries.svelte.d.ts","sourceRoot":"","sources":["../src/createQueries.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EAET,8BAA8B,EAC9B,WAAW,EACX,aAAa,EACb,QAAQ,EACR,YAAY,EACb,MAAM,sBAAsB,CAAA;AAI7B,KAAK,kCAAkC,CACrC,YAAY,GAAG,OAAO,EACtB,MAAM,GAAG,YAAY,EACrB,KAAK,GAAG,YAAY,EACpB,SAAS,SAAS,QAAQ,GAAG,QAAQ,IACnC,SAAS,CACX,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,EAC1D,iBAAiB,CAClB,GAAG;IACF,eAAe,CAAC,EAAE,YAAY,GAAG,8BAA8B,CAAC,YAAY,CAAC,CAAA;CAC9E,CAAA;AAGD,KAAK,aAAa,GAAG,EAAE,CAAA;AAGvB,KAAK,yBAAyB,GAAG,MAAM,CAAA;AAEvC,KAAK,qCAAqC,CAAC,CAAC,IAE1C,CAAC,SAAS;IACR,WAAW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AiB,CAAC,GACxB,CAAC,SAAS,EAAE,GACV,EAAE,GACF,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,GACpB,CAAC,GAAG,QAAQ,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC,GACzC,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,GACpC,cAAc,CACZ;IAAC,GAAG,KAAK;CAAC,EACV;IAAC,GAAG,QAAQ;IAAE,oBAAoB,CAAC,IAAI,CAAC;CAAC,EACzC;IAAC,GAAG,MAAM;IAAE,CAAC;CAAC,CACf,GACD;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,wBAAgB,aAAa,CAC3B,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,EACpB,eAAe,GAAG,cAAc,CAAC,CAAC,CAAC,EAEnC,oBAAoB,EAAE,QAAQ,CAAC;IAC7B,OAAO,EACH,SAAS,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,GAC/B,SAAS;QACP,GAAG;aAAG,CAAC,IAAI,MAAM,CAAC,GAAG,qCAAqC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAAE;KACnE,CAAA;IACL,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,eAAe,CAAA;CACzD,CAAC,EACF,WAAW,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAClC,eAAe,CAwDjB"}
|
|
@@ -4,14 +4,12 @@ import { createRawRef } from './containers.svelte.js';
|
|
|
4
4
|
import { useQueryClient } from './useQueryClient.js';
|
|
5
5
|
/**
|
|
6
6
|
* The `createQueries` function can be used to fetch a variable number of queries.
|
|
7
|
-
*
|
|
8
7
|
* @param createQueriesOptions - The `queries` array to run, and an optional `combine` function, wrapped in an
|
|
9
8
|
* {@link Accessor} so options can be reactive.
|
|
10
9
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context
|
|
11
10
|
* will be used.
|
|
12
11
|
* @returns An array with one result per query, in the same order as `queries` — or, if `combine` is provided,
|
|
13
12
|
* whatever `combine` returns.
|
|
14
|
-
*
|
|
15
13
|
* @example
|
|
16
14
|
* ```svelte
|
|
17
15
|
* <script lang="ts">
|
|
@@ -40,7 +38,6 @@ import { useQueryClient } from './useQueryClient.js';
|
|
|
40
38
|
* {/each}
|
|
41
39
|
* </ul>
|
|
42
40
|
* ```
|
|
43
|
-
*
|
|
44
41
|
* @example
|
|
45
42
|
* Combining results into a single value:
|
|
46
43
|
* ```svelte
|
|
@@ -89,6 +86,10 @@ export function createQueries(createQueriesOptions, queryClient) {
|
|
|
89
86
|
}));
|
|
90
87
|
// can't do same as createMutation, as QueriesObserver has no `setOptions` method
|
|
91
88
|
const observer = $derived(new QueriesObserver(client, resolvedQueryOptions, combine));
|
|
89
|
+
/**
|
|
90
|
+
* Computes the combined result of the observer's queries for the resolved options.
|
|
91
|
+
* @returns The combined result, built from the tracked per-query results.
|
|
92
|
+
*/
|
|
92
93
|
function createResult() {
|
|
93
94
|
const [_, getCombinedResult, trackResult] = observer.getOptimisticResult(resolvedQueryOptions, combine);
|
|
94
95
|
return getCombinedResult(trackResult());
|
package/dist/createQuery.d.ts
CHANGED
|
@@ -7,8 +7,6 @@ import type { DefinedInitialDataOptions, UndefinedInitialDataOptions } from './q
|
|
|
7
7
|
*
|
|
8
8
|
* This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
|
|
9
9
|
* a `select` changes `TData` to include `undefined`).
|
|
10
|
-
*
|
|
11
|
-
* @see {@link queryOptions} to share these options between `createQuery` and imperative APIs like `queryClient.query`.
|
|
12
10
|
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `createQuery`,
|
|
13
11
|
* with `initialData` set, wrapped in an {@link Accessor} so options can be reactive.
|
|
14
12
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
@@ -16,7 +14,7 @@ import type { DefinedInitialDataOptions, UndefinedInitialDataOptions } from './q
|
|
|
16
14
|
* @returns The current query result, typed so that `status` is `success` — or `error` if a fetch attempt
|
|
17
15
|
* fails while keeping the existing data (`status` never resolves to `pending` in this overload's type,
|
|
18
16
|
* since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience.
|
|
19
|
-
*
|
|
17
|
+
* @see {@link queryOptions} to share these options between `createQuery` and imperative APIs like `queryClient.query`.
|
|
20
18
|
* @example
|
|
21
19
|
* ```svelte
|
|
22
20
|
* <script lang="ts">
|
|
@@ -45,8 +43,6 @@ export declare function createQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
45
43
|
/**
|
|
46
44
|
* Subscribes to a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
47
45
|
* The query runs when the options call for it — `enabled: false` skips the initial fetch.
|
|
48
|
-
*
|
|
49
|
-
* @see {@link queryOptions} to share these options between `createQuery` and imperative APIs like `queryClient.query`.
|
|
50
46
|
* @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `createQuery`,
|
|
51
47
|
* wrapped in an {@link Accessor} so options can be reactive.
|
|
52
48
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
@@ -54,7 +50,7 @@ export declare function createQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
54
50
|
* @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if
|
|
55
51
|
* the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError`
|
|
56
52
|
* are derived booleans for convenience.
|
|
57
|
-
*
|
|
53
|
+
* @see {@link queryOptions} to share these options between `createQuery` and imperative APIs like `queryClient.query`.
|
|
58
54
|
* @example
|
|
59
55
|
* ```svelte
|
|
60
56
|
* <script lang="ts">
|
|
@@ -78,7 +74,6 @@ export declare function createQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
78
74
|
* </ul>
|
|
79
75
|
* {/if}
|
|
80
76
|
* ```
|
|
81
|
-
*
|
|
82
77
|
* @example
|
|
83
78
|
* The same query, checking `isPending`/`isError` instead of `status` — pick whichever reads better to you:
|
|
84
79
|
* ```svelte
|
|
@@ -106,7 +101,9 @@ export declare function createQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
106
101
|
*/
|
|
107
102
|
export declare function createQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: Accessor<UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>>, queryClient?: Accessor<QueryClient>): CreateQueryResult<TData, TError>;
|
|
108
103
|
/**
|
|
109
|
-
*
|
|
104
|
+
* Fallback overload for options whose `initialData` presence isn't statically known — for example, an
|
|
105
|
+
* object typed as {@link CreateQueryOptions} rather than an object literal. Prefer one of the other
|
|
106
|
+
* overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.
|
|
110
107
|
* @param options - The {@link CreateQueryOptions} to use — everything you can pass to `createQuery`, wrapped
|
|
111
108
|
* in an {@link Accessor} so options can be reactive.
|
|
112
109
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
@@ -114,7 +111,7 @@ export declare function createQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
114
111
|
* @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if
|
|
115
112
|
* the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError`
|
|
116
113
|
* are derived booleans for convenience.
|
|
117
|
-
*
|
|
114
|
+
* @see {@link queryOptions} to share these options between `createQuery` and imperative APIs like `queryClient.query`.
|
|
118
115
|
* @example
|
|
119
116
|
* `select` derives whatever `data` a component needs from the cached value, without changing what's
|
|
120
117
|
* actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:
|
|
@@ -137,7 +134,6 @@ export declare function createQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
137
134
|
* <span>{query.data} posts</span>
|
|
138
135
|
* {/if}
|
|
139
136
|
* ```
|
|
140
|
-
*
|
|
141
137
|
* @example
|
|
142
138
|
* A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the
|
|
143
139
|
* loading state doesn't show while the query is disabled:
|
|
@@ -164,7 +160,6 @@ export declare function createQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
164
160
|
* <h1>{query.data?.title}</h1>
|
|
165
161
|
* {/if}
|
|
166
162
|
* ```
|
|
167
|
-
*
|
|
168
163
|
* @example
|
|
169
164
|
* Seeding a detail query from an already-cached list, to skip the loading state:
|
|
170
165
|
* ```svelte
|
|
@@ -190,7 +185,6 @@ export declare function createQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
190
185
|
* {/if}
|
|
191
186
|
* <h1>{query.data?.title}</h1>
|
|
192
187
|
* ```
|
|
193
|
-
*
|
|
194
188
|
* @example
|
|
195
189
|
* Paginated data, keeping the previous page's data visible while the next page loads:
|
|
196
190
|
* ```svelte
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createQuery.d.ts","sourceRoot":"","sources":["../src/createQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/E,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,mBAAmB,CAAA;AAE1B
|
|
1
|
+
{"version":3,"file":"createQuery.d.ts","sourceRoot":"","sources":["../src/createQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AA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ErC,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,EAC7E,WAAW,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAClC,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { DefaultError, InfiniteData, InitialDataFunction, NonUndefinedGuard, QueryKey, QueryKeyWithDataTag } from '@tanstack/query-core';
|
|
2
2
|
import type { CreateInfiniteQueryOptions } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is omitted or may
|
|
5
|
+
* be `undefined` — `data` may be `undefined` while the query is `pending`.
|
|
6
|
+
*/
|
|
3
7
|
export type UndefinedInitialDataInfiniteOptions<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
4
8
|
initialData?: undefined | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | InitialDataFunction<NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>>;
|
|
5
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is known to be
|
|
12
|
+
* defined — `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
13
|
+
*/
|
|
6
14
|
export type DefinedInitialDataInfiniteOptions<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
7
15
|
initialData: NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>);
|
|
8
16
|
};
|
|
@@ -12,12 +20,10 @@ export type DefinedInitialDataInfiniteOptions<TQueryFnData = unknown, TError = D
|
|
|
12
20
|
* `queryClient.infiniteQuery`. `options.queryKey` is required and is the query key to generate options for.
|
|
13
21
|
*
|
|
14
22
|
* This overload is selected when `initialData` is known to be defined.
|
|
15
|
-
*
|
|
16
|
-
* @see {@link createInfiniteQuery} to run an infinite query with these options.
|
|
17
23
|
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to
|
|
18
24
|
* `createInfiniteQuery`, with `initialData` set.
|
|
19
25
|
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
20
|
-
*
|
|
26
|
+
* @see {@link createInfiniteQuery} to run an infinite query with these options.
|
|
21
27
|
* @example
|
|
22
28
|
* `initialData` skips the loading state on first render — even if a refetch fails, the list stays
|
|
23
29
|
* visible alongside the error:
|
|
@@ -53,12 +59,10 @@ export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError
|
|
|
53
59
|
* You can generally pass everything to `infiniteQueryOptions` that you can also pass to `createInfiniteQuery`.
|
|
54
60
|
* These options can be shared across `createInfiniteQuery` calls and imperative APIs such as
|
|
55
61
|
* `queryClient.infiniteQuery`. `options.queryKey` is required and is the query key to generate options for.
|
|
56
|
-
*
|
|
57
|
-
* @see {@link createInfiniteQuery} to run an infinite query with these options.
|
|
58
62
|
* @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to
|
|
59
63
|
* `createInfiniteQuery`.
|
|
60
64
|
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
61
|
-
*
|
|
65
|
+
* @see {@link createInfiniteQuery} to run an infinite query with these options.
|
|
62
66
|
* @example
|
|
63
67
|
* A parameterized factory, so the same options object can be reused per `postId`:
|
|
64
68
|
* ```svelte
|