@tanstack/query-core 5.51.21 → 5.52.0
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/{hydration-_zJn9f1s.d.cts → hydration-BhEnbX2k.d.cts} +1 -1
- package/build/legacy/{hydration-zFr_7WN8.d.ts → hydration-CocLapol.d.ts} +1 -1
- package/build/legacy/hydration.d.cts +1 -1
- package/build/legacy/hydration.d.ts +1 -1
- package/build/legacy/index.d.cts +1 -1
- package/build/legacy/index.d.ts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
- package/build/legacy/infiniteQueryObserver.cjs.map +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +6 -5
- package/build/legacy/infiniteQueryObserver.d.ts +6 -5
- package/build/legacy/infiniteQueryObserver.js.map +1 -1
- package/build/legacy/mutation.d.cts +1 -1
- package/build/legacy/mutation.d.ts +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationObserver.d.cts +1 -1
- package/build/legacy/mutationObserver.d.ts +1 -1
- package/build/legacy/queriesObserver.d.cts +1 -1
- package/build/legacy/queriesObserver.d.ts +1 -1
- package/build/legacy/query.d.cts +1 -1
- package/build/legacy/query.d.ts +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryObserver.cjs.map +1 -1
- package/build/legacy/queryObserver.d.cts +1 -1
- package/build/legacy/queryObserver.d.ts +1 -1
- package/build/legacy/queryObserver.js.map +1 -1
- package/build/legacy/retryer.d.cts +1 -1
- package/build/legacy/retryer.d.ts +1 -1
- package/build/legacy/subscribable.cjs.map +1 -1
- package/build/legacy/subscribable.d.cts +1 -2
- package/build/legacy/subscribable.d.ts +1 -2
- package/build/legacy/subscribable.js.map +1 -1
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/utils.d.cts +1 -1
- package/build/legacy/utils.d.ts +1 -1
- package/build/modern/{hydration-_zJn9f1s.d.cts → hydration-BhEnbX2k.d.cts} +1 -1
- package/build/modern/{hydration-zFr_7WN8.d.ts → hydration-CocLapol.d.ts} +1 -1
- package/build/modern/hydration.d.cts +1 -1
- package/build/modern/hydration.d.ts +1 -1
- package/build/modern/index.d.cts +1 -1
- package/build/modern/index.d.ts +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +1 -1
- package/build/modern/infiniteQueryObserver.cjs.map +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +6 -5
- package/build/modern/infiniteQueryObserver.d.ts +6 -5
- package/build/modern/infiniteQueryObserver.js.map +1 -1
- package/build/modern/mutation.d.cts +1 -1
- package/build/modern/mutation.d.ts +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationObserver.d.cts +1 -1
- package/build/modern/mutationObserver.d.ts +1 -1
- package/build/modern/queriesObserver.d.cts +1 -1
- package/build/modern/queriesObserver.d.ts +1 -1
- package/build/modern/query.d.cts +1 -1
- package/build/modern/query.d.ts +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryObserver.cjs.map +1 -1
- package/build/modern/queryObserver.d.cts +1 -1
- package/build/modern/queryObserver.d.ts +1 -1
- package/build/modern/queryObserver.js.map +1 -1
- package/build/modern/retryer.d.cts +1 -1
- package/build/modern/retryer.d.ts +1 -1
- package/build/modern/subscribable.cjs.map +1 -1
- package/build/modern/subscribable.d.cts +1 -2
- package/build/modern/subscribable.d.ts +1 -2
- package/build/modern/subscribable.js.map +1 -1
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/utils.d.cts +1 -1
- package/build/modern/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/OmitKeyof.test-d.ts +12 -12
- package/src/__tests__/mutations.test.tsx +2 -2
- package/src/__tests__/queryClient.test.tsx +4 -4
- package/src/__tests__/queryObserver.test.tsx +2 -2
- package/src/infiniteQueryObserver.ts +30 -8
- package/src/queryObserver.ts +1 -1
- package/src/subscribable.ts +2 -5
|
@@ -218,13 +218,13 @@ describe('queryClient', () => {
|
|
|
218
218
|
expect(testCache.find({ queryKey: key })).toBe(testCache.get('someKey'))
|
|
219
219
|
})
|
|
220
220
|
|
|
221
|
-
test('should create a new query if query was not found', () => {
|
|
221
|
+
test('should create a new query if query was not found 1', () => {
|
|
222
222
|
const key = queryKey()
|
|
223
223
|
queryClient.setQueryData(key, 'bar')
|
|
224
224
|
expect(queryClient.getQueryData(key)).toBe('bar')
|
|
225
225
|
})
|
|
226
226
|
|
|
227
|
-
test('should create a new query if query was not found', () => {
|
|
227
|
+
test('should create a new query if query was not found 2', () => {
|
|
228
228
|
const key = queryKey()
|
|
229
229
|
queryClient.setQueryData(key, 'qux')
|
|
230
230
|
expect(queryClient.getQueryData(key)).toBe('qux')
|
|
@@ -1074,7 +1074,7 @@ describe('queryClient', () => {
|
|
|
1074
1074
|
expect(queryFn2).toHaveBeenCalledTimes(1)
|
|
1075
1075
|
})
|
|
1076
1076
|
|
|
1077
|
-
test('should be able to refetch all active and inactive queries', async () => {
|
|
1077
|
+
test('should be able to refetch all active and inactive queries (queryClient.refetchQueries()', async () => {
|
|
1078
1078
|
const key1 = queryKey()
|
|
1079
1079
|
const key2 = queryKey()
|
|
1080
1080
|
const queryFn1 = vi
|
|
@@ -1097,7 +1097,7 @@ describe('queryClient', () => {
|
|
|
1097
1097
|
expect(queryFn2).toHaveBeenCalledTimes(2)
|
|
1098
1098
|
})
|
|
1099
1099
|
|
|
1100
|
-
test('should be able to refetch all active and inactive queries', async () => {
|
|
1100
|
+
test('should be able to refetch all active and inactive queries (queryClient.refetchQueries({ type: "all" }))', async () => {
|
|
1101
1101
|
const key1 = queryKey()
|
|
1102
1102
|
const key2 = queryKey()
|
|
1103
1103
|
const queryFn1 = vi
|
|
@@ -157,7 +157,7 @@ describe('queryObserver', () => {
|
|
|
157
157
|
unsubscribe()
|
|
158
158
|
})
|
|
159
159
|
|
|
160
|
-
test('should not be re-fetched if not subscribed to after enabled was toggled to true', async () => {
|
|
160
|
+
test('should not be re-fetched if not subscribed to after enabled was toggled to true (fetchStatus: "idle")', async () => {
|
|
161
161
|
const unsubscribe = observer.subscribe(vi.fn())
|
|
162
162
|
|
|
163
163
|
// Toggle enabled
|
|
@@ -175,7 +175,7 @@ describe('queryObserver', () => {
|
|
|
175
175
|
expect(count).toBe(0)
|
|
176
176
|
})
|
|
177
177
|
|
|
178
|
-
test('should not be re-fetched if not subscribed to after enabled was toggled to true', async () => {
|
|
178
|
+
test('should not be re-fetched if not subscribed to after enabled was toggled to true (fetchStatus: "fetching")', async () => {
|
|
179
179
|
const unsubscribe = observer.subscribe(vi.fn())
|
|
180
180
|
|
|
181
181
|
// Toggle enabled
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
hasPreviousPage,
|
|
5
5
|
infiniteQueryBehavior,
|
|
6
6
|
} from './infiniteQueryBehavior'
|
|
7
|
+
import type { Subscribable } from './subscribable'
|
|
7
8
|
import type {
|
|
8
9
|
DefaultError,
|
|
9
10
|
DefaultedInfiniteQueryObserverOptions,
|
|
@@ -16,7 +17,7 @@ import type {
|
|
|
16
17
|
QueryKey,
|
|
17
18
|
} from './types'
|
|
18
19
|
import type { QueryClient } from './queryClient'
|
|
19
|
-
import type { NotifyOptions
|
|
20
|
+
import type { NotifyOptions } from './queryObserver'
|
|
20
21
|
import type { Query } from './query'
|
|
21
22
|
|
|
22
23
|
type InfiniteQueryObserverListener<TData, TError> = (
|
|
@@ -38,17 +39,33 @@ export class InfiniteQueryObserver<
|
|
|
38
39
|
TQueryKey
|
|
39
40
|
> {
|
|
40
41
|
// Type override
|
|
41
|
-
subscribe!:
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
subscribe!: Subscribable<
|
|
43
|
+
InfiniteQueryObserverListener<TData, TError>
|
|
44
|
+
>['subscribe']
|
|
44
45
|
|
|
45
46
|
// Type override
|
|
46
|
-
getCurrentResult!:
|
|
47
|
+
getCurrentResult!: ReplaceReturnType<
|
|
48
|
+
QueryObserver<
|
|
49
|
+
TQueryFnData,
|
|
50
|
+
TError,
|
|
51
|
+
TData,
|
|
52
|
+
InfiniteData<TQueryData, TPageParam>,
|
|
53
|
+
TQueryKey
|
|
54
|
+
>['getCurrentResult'],
|
|
55
|
+
InfiniteQueryObserverResult<TData, TError>
|
|
56
|
+
>
|
|
47
57
|
|
|
48
58
|
// Type override
|
|
49
|
-
protected fetch!:
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
protected fetch!: ReplaceReturnType<
|
|
60
|
+
QueryObserver<
|
|
61
|
+
TQueryFnData,
|
|
62
|
+
TError,
|
|
63
|
+
TData,
|
|
64
|
+
InfiniteData<TQueryData, TPageParam>,
|
|
65
|
+
TQueryKey
|
|
66
|
+
>['fetch'],
|
|
67
|
+
Promise<InfiniteQueryObserverResult<TData, TError>>
|
|
68
|
+
>
|
|
52
69
|
|
|
53
70
|
constructor(
|
|
54
71
|
client: QueryClient,
|
|
@@ -176,3 +193,8 @@ export class InfiniteQueryObserver<
|
|
|
176
193
|
return result as InfiniteQueryObserverResult<TData, TError>
|
|
177
194
|
}
|
|
178
195
|
}
|
|
196
|
+
|
|
197
|
+
type ReplaceReturnType<
|
|
198
|
+
TFunction extends (...args: Array<any>) => unknown,
|
|
199
|
+
TReturn,
|
|
200
|
+
> = (...args: Parameters<TFunction>) => TReturn
|
package/src/queryObserver.ts
CHANGED
package/src/subscribable.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export class Subscribable<TListener extends Function = Listener> {
|
|
4
|
-
protected listeners: Set<TListener>
|
|
1
|
+
export class Subscribable<TListener extends Function> {
|
|
2
|
+
protected listeners = new Set<TListener>()
|
|
5
3
|
|
|
6
4
|
constructor() {
|
|
7
|
-
this.listeners = new Set()
|
|
8
5
|
this.subscribe = this.subscribe.bind(this)
|
|
9
6
|
}
|
|
10
7
|
|