@tanstack/vue-query 5.0.0-beta.6 → 5.0.0-rc.1
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/build/legacy/devtools/devtools.cjs.map +1 -1
- package/build/legacy/devtools/devtools.js.map +1 -1
- package/build/legacy/index.d.cts +2 -2
- package/build/legacy/index.d.ts +2 -2
- package/build/legacy/mutationCache.cjs.map +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationCache.js.map +1 -1
- package/build/legacy/queryCache.cjs.map +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryCache.js.map +1 -1
- package/build/legacy/queryClient.cjs +3 -4
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +5 -5
- package/build/legacy/queryClient.d.ts +5 -5
- package/build/legacy/queryClient.js +3 -4
- package/build/legacy/queryClient.js.map +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +7 -2
- package/build/legacy/types.d.ts +7 -2
- package/build/legacy/useBaseQuery.cjs +40 -20
- package/build/legacy/useBaseQuery.cjs.map +1 -1
- package/build/legacy/useBaseQuery.d.cts +1 -1
- package/build/legacy/useBaseQuery.d.ts +1 -1
- package/build/legacy/useBaseQuery.js +42 -21
- package/build/legacy/useBaseQuery.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +1 -1
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +13 -13
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.js +14 -14
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +16 -1
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.js +18 -2
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.cjs +10 -7
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.js +18 -8
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/useQueries.cjs +9 -2
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +7 -5
- package/build/legacy/useQueries.d.ts +7 -5
- package/build/legacy/useQueries.js +17 -3
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/{useQuery-ebff9211.d.ts → useQuery-42d67167.d.ts} +6 -6
- package/build/legacy/{useQuery-846c66db.d.ts → useQuery-ac350b9a.d.ts} +6 -6
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +1 -1
- package/build/legacy/useQuery.d.ts +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useQueryClient.cjs +4 -4
- package/build/legacy/useQueryClient.cjs.map +1 -1
- package/build/legacy/useQueryClient.js +5 -5
- package/build/legacy/useQueryClient.js.map +1 -1
- package/build/legacy/utils.cjs +8 -0
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +2 -1
- package/build/legacy/utils.d.ts +2 -1
- package/build/legacy/utils.js +7 -0
- package/build/legacy/utils.js.map +1 -1
- package/build/legacy/vueQueryPlugin.cjs +2 -0
- package/build/legacy/vueQueryPlugin.cjs.map +1 -1
- package/build/legacy/vueQueryPlugin.d.cts +3 -2
- package/build/legacy/vueQueryPlugin.d.ts +3 -2
- package/build/legacy/vueQueryPlugin.js +2 -0
- package/build/legacy/vueQueryPlugin.js.map +1 -1
- package/build/modern/devtools/devtools.cjs.map +1 -1
- package/build/modern/devtools/devtools.js.map +1 -1
- package/build/modern/index.d.cts +2 -2
- package/build/modern/index.d.ts +2 -2
- package/build/modern/mutationCache.cjs.map +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationCache.js.map +1 -1
- package/build/modern/queryCache.cjs.map +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryCache.js.map +1 -1
- package/build/modern/queryClient.cjs +3 -4
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +5 -5
- package/build/modern/queryClient.d.ts +5 -5
- package/build/modern/queryClient.js +3 -4
- package/build/modern/queryClient.js.map +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +7 -2
- package/build/modern/types.d.ts +7 -2
- package/build/modern/useBaseQuery.cjs +40 -20
- package/build/modern/useBaseQuery.cjs.map +1 -1
- package/build/modern/useBaseQuery.d.cts +1 -1
- package/build/modern/useBaseQuery.d.ts +1 -1
- package/build/modern/useBaseQuery.js +42 -21
- package/build/modern/useBaseQuery.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +1 -1
- package/build/modern/useInfiniteQuery.d.ts +1 -1
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +13 -13
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.js +14 -14
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +16 -1
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.js +18 -2
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.cjs +10 -7
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.js +18 -8
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/useQueries.cjs +9 -2
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +7 -5
- package/build/modern/useQueries.d.ts +7 -5
- package/build/modern/useQueries.js +17 -3
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/{useQuery-ebff9211.d.ts → useQuery-42d67167.d.ts} +6 -6
- package/build/modern/{useQuery-846c66db.d.ts → useQuery-ac350b9a.d.ts} +6 -6
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +1 -1
- package/build/modern/useQuery.d.ts +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useQueryClient.cjs +4 -3
- package/build/modern/useQueryClient.cjs.map +1 -1
- package/build/modern/useQueryClient.js +5 -4
- package/build/modern/useQueryClient.js.map +1 -1
- package/build/modern/utils.cjs +8 -0
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +2 -1
- package/build/modern/utils.d.ts +2 -1
- package/build/modern/utils.js +7 -0
- package/build/modern/utils.js.map +1 -1
- package/build/modern/vueQueryPlugin.cjs +1 -0
- package/build/modern/vueQueryPlugin.cjs.map +1 -1
- package/build/modern/vueQueryPlugin.d.cts +3 -2
- package/build/modern/vueQueryPlugin.d.ts +3 -2
- package/build/modern/vueQueryPlugin.js +1 -0
- package/build/modern/vueQueryPlugin.js.map +1 -1
- package/package.json +6 -6
- package/src/__mocks__/useBaseQuery.ts +1 -1
- package/src/__tests__/queryClient.test.ts +4 -4
- package/src/__tests__/useInfiniteQuery.test.ts +1 -1
- package/src/__tests__/useInfiniteQuery.types.test.tsx +11 -8
- package/src/__tests__/useMutation.test.ts +23 -3
- package/src/__tests__/useQuery.test.ts +57 -6
- package/src/__tests__/useQueryClient.test.ts +4 -4
- package/src/__tests__/utils.test.ts +1 -1
- package/src/devtools/devtools.ts +2 -2
- package/src/mutationCache.ts +1 -1
- package/src/queryCache.ts +1 -1
- package/src/queryClient.ts +19 -12
- package/src/types.ts +23 -1
- package/src/useBaseQuery.ts +51 -21
- package/src/useInfiniteQuery.ts +2 -3
- package/src/useIsFetching.ts +16 -14
- package/src/useMutation.ts +23 -2
- package/src/useMutationState.ts +20 -9
- package/src/useQueries.ts +51 -28
- package/src/useQuery.ts +10 -5
- package/src/useQueryClient.ts +6 -5
- package/src/utils.ts +12 -0
- package/src/vueQueryPlugin.ts +3 -2
package/src/useMutationState.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
getCurrentScope,
|
|
4
|
+
onScopeDispose,
|
|
5
|
+
readonly,
|
|
6
|
+
ref,
|
|
7
|
+
watch,
|
|
8
|
+
} from 'vue-demi'
|
|
2
9
|
import { useQueryClient } from './useQueryClient'
|
|
3
10
|
import { cloneDeepUnref } from './utils'
|
|
4
11
|
import type { DeepReadonly, Ref } from 'vue-demi'
|
|
@@ -18,6 +25,14 @@ export function useIsMutating(
|
|
|
18
25
|
filters: MutationFilters = {},
|
|
19
26
|
queryClient?: QueryClient,
|
|
20
27
|
): Ref<number> {
|
|
28
|
+
if (process.env.NODE_ENV === 'development') {
|
|
29
|
+
if (!getCurrentScope()) {
|
|
30
|
+
console.warn(
|
|
31
|
+
'vue-query composables like "uesQuery()" should only be used inside a "setup()" function or a running effect scope. They might otherwise lead to memory leaks.',
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
21
36
|
const client = queryClient || useQueryClient()
|
|
22
37
|
const unreffedFilters = computed(() => ({
|
|
23
38
|
...cloneDeepUnref(filters),
|
|
@@ -59,19 +74,15 @@ export function useMutationState<TResult = MutationState>(
|
|
|
59
74
|
): DeepReadonly<Ref<Array<TResult>>> {
|
|
60
75
|
const filters = computed(() => cloneDeepUnref(options.filters))
|
|
61
76
|
const mutationCache = (queryClient || useQueryClient()).getMutationCache()
|
|
62
|
-
const state = ref(getResult(mutationCache, options)) as Ref<TResult
|
|
77
|
+
const state = ref(getResult(mutationCache, options)) as Ref<Array<TResult>>
|
|
63
78
|
const unsubscribe = mutationCache.subscribe(() => {
|
|
64
79
|
const result = getResult(mutationCache, options)
|
|
65
80
|
state.value = result
|
|
66
81
|
})
|
|
67
82
|
|
|
68
|
-
watch(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
state.value = getResult(mutationCache, options)
|
|
72
|
-
},
|
|
73
|
-
{ deep: true },
|
|
74
|
-
)
|
|
83
|
+
watch(filters, () => {
|
|
84
|
+
state.value = getResult(mutationCache, options)
|
|
85
|
+
})
|
|
75
86
|
|
|
76
87
|
onScopeDispose(() => {
|
|
77
88
|
unsubscribe()
|
package/src/useQueries.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { QueriesObserver } from '@tanstack/query-core'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
computed,
|
|
5
|
+
getCurrentScope,
|
|
6
|
+
onScopeDispose,
|
|
7
|
+
readonly,
|
|
8
|
+
ref,
|
|
9
|
+
watch,
|
|
10
|
+
} from 'vue-demi'
|
|
4
11
|
|
|
5
12
|
import { useQueryClient } from './useQueryClient'
|
|
6
13
|
import { cloneDeepUnref } from './utils'
|
|
@@ -93,61 +100,69 @@ type GetResults<T> =
|
|
|
93
100
|
* UseQueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
|
|
94
101
|
*/
|
|
95
102
|
export type UseQueriesOptions<
|
|
96
|
-
T extends any
|
|
97
|
-
Result extends any
|
|
103
|
+
T extends Array<any>,
|
|
104
|
+
Result extends Array<any> = [],
|
|
98
105
|
Depth extends ReadonlyArray<number> = [],
|
|
99
106
|
> = Depth['length'] extends MAXIMUM_DEPTH
|
|
100
|
-
? UseQueryOptionsForUseQueries
|
|
107
|
+
? Array<UseQueryOptionsForUseQueries>
|
|
101
108
|
: T extends []
|
|
102
109
|
? []
|
|
103
110
|
: T extends [infer Head]
|
|
104
111
|
? [...Result, GetOptions<Head>]
|
|
105
112
|
: T extends [infer Head, ...infer Tail]
|
|
106
113
|
? UseQueriesOptions<[...Tail], [...Result, GetOptions<Head>], [...Depth, 1]>
|
|
107
|
-
: unknown
|
|
114
|
+
: Array<unknown> extends T
|
|
108
115
|
? T
|
|
109
116
|
: // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogenous type!
|
|
110
117
|
// use this to infer the param types in the case of Array.map() argument
|
|
111
|
-
T extends
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
T extends Array<
|
|
119
|
+
UseQueryOptionsForUseQueries<
|
|
120
|
+
infer TQueryFnData,
|
|
121
|
+
infer TError,
|
|
122
|
+
infer TData,
|
|
123
|
+
infer TQueryKey
|
|
124
|
+
>
|
|
125
|
+
>
|
|
126
|
+
? Array<UseQueryOptionsForUseQueries<TQueryFnData, TError, TData, TQueryKey>>
|
|
118
127
|
: // Fallback
|
|
119
|
-
UseQueryOptionsForUseQueries
|
|
128
|
+
Array<UseQueryOptionsForUseQueries>
|
|
120
129
|
|
|
121
130
|
/**
|
|
122
131
|
* UseQueriesResults reducer recursively maps type param to results
|
|
123
132
|
*/
|
|
124
133
|
export type UseQueriesResults<
|
|
125
|
-
T extends any
|
|
126
|
-
Result extends any
|
|
134
|
+
T extends Array<any>,
|
|
135
|
+
Result extends Array<any> = [],
|
|
127
136
|
Depth extends ReadonlyArray<number> = [],
|
|
128
137
|
> = Depth['length'] extends MAXIMUM_DEPTH
|
|
129
|
-
? QueryObserverResult
|
|
138
|
+
? Array<QueryObserverResult>
|
|
130
139
|
: T extends []
|
|
131
140
|
? []
|
|
132
141
|
: T extends [infer Head]
|
|
133
142
|
? [...Result, GetResults<Head>]
|
|
134
143
|
: T extends [infer Head, ...infer Tail]
|
|
135
144
|
? UseQueriesResults<[...Tail], [...Result, GetResults<Head>], [...Depth, 1]>
|
|
136
|
-
: T extends
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
145
|
+
: T extends Array<
|
|
146
|
+
UseQueryOptionsForUseQueries<
|
|
147
|
+
infer TQueryFnData,
|
|
148
|
+
infer TError,
|
|
149
|
+
infer TData,
|
|
150
|
+
any
|
|
151
|
+
>
|
|
152
|
+
>
|
|
142
153
|
? // Dynamic-size (homogenous) UseQueryOptions array: map directly to array of results
|
|
143
|
-
|
|
154
|
+
Array<
|
|
155
|
+
QueryObserverResult<unknown extends TData ? TQueryFnData : TData, TError>
|
|
156
|
+
>
|
|
144
157
|
: // Fallback
|
|
145
|
-
QueryObserverResult
|
|
158
|
+
Array<QueryObserverResult>
|
|
146
159
|
|
|
147
|
-
type UseQueriesOptionsArg<T extends any
|
|
160
|
+
type UseQueriesOptionsArg<T extends Array<any>> = readonly [
|
|
161
|
+
...UseQueriesOptions<T>,
|
|
162
|
+
]
|
|
148
163
|
|
|
149
164
|
export function useQueries<
|
|
150
|
-
T extends any
|
|
165
|
+
T extends Array<any>,
|
|
151
166
|
TCombinedResult = UseQueriesResults<T>,
|
|
152
167
|
>(
|
|
153
168
|
{
|
|
@@ -159,6 +174,14 @@ export function useQueries<
|
|
|
159
174
|
},
|
|
160
175
|
queryClient?: QueryClient,
|
|
161
176
|
): Readonly<Ref<TCombinedResult>> {
|
|
177
|
+
if (process.env.NODE_ENV === 'development') {
|
|
178
|
+
if (!getCurrentScope()) {
|
|
179
|
+
console.warn(
|
|
180
|
+
'vue-query composables like "uesQuery()" should only be used inside a "setup()" function or a running effect scope. They might otherwise lead to memory leaks.',
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
162
185
|
const client = queryClient || useQueryClient()
|
|
163
186
|
|
|
164
187
|
const defaultedQueries = computed(() =>
|
|
@@ -208,7 +231,7 @@ export function useQueries<
|
|
|
208
231
|
)
|
|
209
232
|
|
|
210
233
|
watch(
|
|
211
|
-
|
|
234
|
+
defaultedQueries,
|
|
212
235
|
() => {
|
|
213
236
|
observer.setQueries(
|
|
214
237
|
defaultedQueries.value,
|
|
@@ -219,7 +242,7 @@ export function useQueries<
|
|
|
219
242
|
)
|
|
220
243
|
state.value = getCombinedResultPersisted()
|
|
221
244
|
},
|
|
222
|
-
{
|
|
245
|
+
{ flush: 'sync' },
|
|
223
246
|
)
|
|
224
247
|
|
|
225
248
|
onScopeDispose(() => {
|
package/src/useQuery.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueryObserver } from '@tanstack/query-core'
|
|
2
2
|
import { useBaseQuery } from './useBaseQuery'
|
|
3
|
-
import type { ToRefs
|
|
3
|
+
import type { ToRefs } from 'vue-demi'
|
|
4
4
|
import type {
|
|
5
5
|
DefaultError,
|
|
6
6
|
DefinedQueryObserverResult,
|
|
@@ -10,7 +10,12 @@ import type {
|
|
|
10
10
|
WithRequired,
|
|
11
11
|
} from '@tanstack/query-core'
|
|
12
12
|
import type { UseBaseQueryReturnType } from './useBaseQuery'
|
|
13
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
DeepUnwrapRef,
|
|
15
|
+
DistributiveOmit,
|
|
16
|
+
MaybeRef,
|
|
17
|
+
MaybeRefDeep,
|
|
18
|
+
} from './types'
|
|
14
19
|
import type { QueryClient } from './queryClient'
|
|
15
20
|
|
|
16
21
|
export type UseQueryOptions<
|
|
@@ -19,7 +24,7 @@ export type UseQueryOptions<
|
|
|
19
24
|
TData = TQueryFnData,
|
|
20
25
|
TQueryData = TQueryFnData,
|
|
21
26
|
TQueryKey extends QueryKey = QueryKey,
|
|
22
|
-
> = {
|
|
27
|
+
> = MaybeRef<{
|
|
23
28
|
[Property in keyof QueryObserverOptions<
|
|
24
29
|
TQueryFnData,
|
|
25
30
|
TError,
|
|
@@ -32,7 +37,7 @@ export type UseQueryOptions<
|
|
|
32
37
|
TError,
|
|
33
38
|
TData,
|
|
34
39
|
TQueryData,
|
|
35
|
-
|
|
40
|
+
DeepUnwrapRef<TQueryKey>
|
|
36
41
|
>[Property]
|
|
37
42
|
: MaybeRefDeep<
|
|
38
43
|
WithRequired<
|
|
@@ -46,7 +51,7 @@ export type UseQueryOptions<
|
|
|
46
51
|
'queryKey'
|
|
47
52
|
>[Property]
|
|
48
53
|
>
|
|
49
|
-
}
|
|
54
|
+
}>
|
|
50
55
|
|
|
51
56
|
export type UseQueryReturnType<TData, TError> = DistributiveOmit<
|
|
52
57
|
UseBaseQueryReturnType<TData, TError>,
|
package/src/useQueryClient.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasInjectionContext, inject } from 'vue-demi'
|
|
2
2
|
|
|
3
3
|
import { getClientKey } from './utils'
|
|
4
4
|
import type { QueryClient } from './queryClient'
|
|
5
5
|
|
|
6
6
|
export function useQueryClient(id = ''): QueryClient {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
// ensures that `inject()` can be used
|
|
8
|
+
if (!hasInjectionContext()) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
'vue-query hooks can only be used inside setup() function or functions that support injection context.',
|
|
11
|
+
)
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const key = getClientKey(id)
|
package/src/utils.ts
CHANGED
|
@@ -65,3 +65,15 @@ function isPlainObject(value: unknown): value is Object {
|
|
|
65
65
|
const prototype = Object.getPrototypeOf(value)
|
|
66
66
|
return prototype === null || prototype === Object.prototype
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
export function shouldThrowError<T extends (...args: Array<any>) => boolean>(
|
|
70
|
+
throwOnError: boolean | T | undefined,
|
|
71
|
+
params: Parameters<T>,
|
|
72
|
+
): boolean {
|
|
73
|
+
// Allow throwOnError function to override throwing behavior on a per-error basis
|
|
74
|
+
if (typeof throwOnError === 'function') {
|
|
75
|
+
return throwOnError(...params)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return !!throwOnError
|
|
79
|
+
}
|
package/src/vueQueryPlugin.ts
CHANGED
|
@@ -5,17 +5,17 @@ import { QueryClient } from './queryClient'
|
|
|
5
5
|
import { getClientKey } from './utils'
|
|
6
6
|
import { setupDevtools } from './devtools/devtools'
|
|
7
7
|
import type { QueryClientConfig } from '@tanstack/query-core'
|
|
8
|
-
import type { MaybeRefDeep } from './types'
|
|
9
8
|
|
|
10
9
|
type ClientPersister = (client: QueryClient) => [() => void, Promise<void>]
|
|
11
10
|
|
|
12
11
|
interface CommonOptions {
|
|
13
12
|
queryClientKey?: string
|
|
14
13
|
clientPersister?: ClientPersister
|
|
14
|
+
clientPersisterOnSuccess?: (client: QueryClient) => void
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
interface ConfigOptions extends CommonOptions {
|
|
18
|
-
queryClientConfig?:
|
|
18
|
+
queryClientConfig?: QueryClientConfig
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
interface ClientOptions extends CommonOptions {
|
|
@@ -51,6 +51,7 @@ export const VueQueryPlugin = {
|
|
|
51
51
|
persisterUnmount = unmount
|
|
52
52
|
promise.then(() => {
|
|
53
53
|
client.isRestoring.value = false
|
|
54
|
+
options.clientPersisterOnSuccess?.(client)
|
|
54
55
|
})
|
|
55
56
|
}
|
|
56
57
|
|