@tanstack/svelte-query 5.0.0-alpha.2 → 5.0.0-alpha.21
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.
|
@@ -8,16 +8,6 @@ export function createBaseQuery(options, Observer, queryClient) {
|
|
|
8
8
|
const defaultedOptionsStore = derived(optionsStore, ($options) => {
|
|
9
9
|
const defaultedOptions = client.defaultQueryOptions($options);
|
|
10
10
|
defaultedOptions._optimisticResults = 'optimistic';
|
|
11
|
-
// Include callbacks in batch renders
|
|
12
|
-
if (defaultedOptions.onError) {
|
|
13
|
-
defaultedOptions.onError = notifyManager.batchCalls(defaultedOptions.onError);
|
|
14
|
-
}
|
|
15
|
-
if (defaultedOptions.onSuccess) {
|
|
16
|
-
defaultedOptions.onSuccess = notifyManager.batchCalls(defaultedOptions.onSuccess);
|
|
17
|
-
}
|
|
18
|
-
if (defaultedOptions.onSettled) {
|
|
19
|
-
defaultedOptions.onSettled = notifyManager.batchCalls(defaultedOptions.onSettled);
|
|
20
|
-
}
|
|
21
11
|
return defaultedOptions;
|
|
22
12
|
});
|
|
23
13
|
const observer = new Observer(client, get(defaultedOptionsStore));
|
|
@@ -46,8 +46,7 @@ export declare type QueriesOptions<T extends any[], Result extends any[] = [], D
|
|
|
46
46
|
*/
|
|
47
47
|
export declare type QueriesResults<T extends any[], Result extends any[] = [], Depth extends ReadonlyArray<number> = []> = Depth['length'] extends MAXIMUM_DEPTH ? QueryObserverResult[] : T extends [] ? [] : T extends [infer Head] ? [...Result, GetResults<Head>] : T extends [infer Head, ...infer Tail] ? QueriesResults<[...Tail], [...Result, GetResults<Head>], [...Depth, 1]> : T extends CreateQueryOptionsForCreateQueries<infer TQueryFnData, infer TError, infer TData, any>[] ? QueryObserverResult<unknown extends TData ? TQueryFnData : TData, unknown extends TError ? DefaultError : TError>[] : QueryObserverResult[];
|
|
48
48
|
export declare type CreateQueriesResult<T extends any[]> = Readable<QueriesResults<T>>;
|
|
49
|
-
export declare function createQueries<T extends any[]>({ queries,
|
|
49
|
+
export declare function createQueries<T extends any[]>({ queries, }: {
|
|
50
50
|
queries: WritableOrVal<[...QueriesOptions<T>]>;
|
|
51
|
-
|
|
52
|
-
}): CreateQueriesResult<T>;
|
|
51
|
+
}, queryClient?: QueryClient): CreateQueriesResult<T>;
|
|
53
52
|
export {};
|
|
@@ -2,7 +2,7 @@ import { notifyManager, QueriesObserver } from '@tanstack/query-core';
|
|
|
2
2
|
import { derived, get, readable, writable } from 'svelte/store';
|
|
3
3
|
import { useQueryClient } from './useQueryClient';
|
|
4
4
|
import { isWritable } from './utils';
|
|
5
|
-
export function createQueries({ queries,
|
|
5
|
+
export function createQueries({ queries, }, queryClient) {
|
|
6
6
|
const client = useQueryClient(queryClient);
|
|
7
7
|
// const isRestoring = useIsRestoring()
|
|
8
8
|
const queriesStore = isWritable(queries) ? queries : writable(queries);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/svelte-query",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.21",
|
|
4
4
|
"description": "Primitives for managing, caching and syncing asynchronous and remote data in Svelte",
|
|
5
5
|
"author": "Dre Johnson",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,21 +14,19 @@
|
|
|
14
14
|
"module": "build/lib/index.js",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@sveltejs/package": "^
|
|
17
|
+
"@sveltejs/package": "^2.0.2",
|
|
18
18
|
"@sveltejs/vite-plugin-svelte": "^2.0.2",
|
|
19
19
|
"@testing-library/svelte": "^3.2.2",
|
|
20
|
-
"@vitest/coverage-istanbul": "^0.27.1",
|
|
21
20
|
"eslint-plugin-svelte": "^2.14.1",
|
|
22
21
|
"jsdom": "^20.0.3",
|
|
23
22
|
"svelte": "^3.54.0",
|
|
24
23
|
"svelte-check": "^2.9.2",
|
|
25
24
|
"tslib": "^2.4.1",
|
|
26
25
|
"typescript": "^4.7.4",
|
|
27
|
-
"vite": "^4.0.0"
|
|
28
|
-
"vitest": "^0.27.1"
|
|
26
|
+
"vite": "^4.0.0"
|
|
29
27
|
},
|
|
30
28
|
"dependencies": {
|
|
31
|
-
"@tanstack/query-core": "5.0.0-alpha.
|
|
29
|
+
"@tanstack/query-core": "5.0.0-alpha.21"
|
|
32
30
|
},
|
|
33
31
|
"peerDependencies": {
|
|
34
32
|
"svelte": "^3.54.0"
|
|
@@ -46,8 +44,8 @@
|
|
|
46
44
|
"clean": "rimraf ./build",
|
|
47
45
|
"test:types": "svelte-check --tsconfig ./tsconfig.json",
|
|
48
46
|
"test:eslint": "eslint --ext .svelte,.ts ./src",
|
|
49
|
-
"test:lib": "vitest run --coverage
|
|
50
|
-
"test:lib:dev": "
|
|
51
|
-
"build": "svelte-package && rimraf ./build/lib/
|
|
47
|
+
"test:lib": "vitest run --coverage",
|
|
48
|
+
"test:lib:dev": "pnpm run test:lib --watch",
|
|
49
|
+
"build": "svelte-package --input ./src --output ./build/lib && rimraf ./build/lib/__tests__"
|
|
52
50
|
}
|
|
53
51
|
}
|
package/src/createBaseQuery.ts
CHANGED
|
@@ -30,25 +30,6 @@ export function createBaseQuery<
|
|
|
30
30
|
const defaultedOptions = client.defaultQueryOptions($options)
|
|
31
31
|
defaultedOptions._optimisticResults = 'optimistic'
|
|
32
32
|
|
|
33
|
-
// Include callbacks in batch renders
|
|
34
|
-
if (defaultedOptions.onError) {
|
|
35
|
-
defaultedOptions.onError = notifyManager.batchCalls(
|
|
36
|
-
defaultedOptions.onError,
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (defaultedOptions.onSuccess) {
|
|
41
|
-
defaultedOptions.onSuccess = notifyManager.batchCalls(
|
|
42
|
-
defaultedOptions.onSuccess,
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (defaultedOptions.onSettled) {
|
|
47
|
-
defaultedOptions.onSettled = notifyManager.batchCalls(
|
|
48
|
-
defaultedOptions.onSettled,
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
33
|
return defaultedOptions
|
|
53
34
|
})
|
|
54
35
|
|
package/src/createQueries.ts
CHANGED
|
@@ -152,13 +152,14 @@ export type QueriesResults<
|
|
|
152
152
|
|
|
153
153
|
export type CreateQueriesResult<T extends any[]> = Readable<QueriesResults<T>>
|
|
154
154
|
|
|
155
|
-
export function createQueries<T extends any[]>(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}: {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
export function createQueries<T extends any[]>(
|
|
156
|
+
{
|
|
157
|
+
queries,
|
|
158
|
+
}: {
|
|
159
|
+
queries: WritableOrVal<[...QueriesOptions<T>]>
|
|
160
|
+
},
|
|
161
|
+
queryClient?: QueryClient,
|
|
162
|
+
): CreateQueriesResult<T> {
|
|
162
163
|
const client = useQueryClient(queryClient)
|
|
163
164
|
// const isRestoring = useIsRestoring()
|
|
164
165
|
|