@tanstack/angular-query-experimental 5.84.0 → 5.84.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/package.json +7 -43
- package/src/create-base-query.ts +0 -142
- package/src/index.ts +0 -64
- package/src/infinite-query-options.ts +0 -187
- package/src/inject-infinite-query.ts +0 -129
- package/src/inject-is-fetching.ts +0 -66
- package/src/inject-is-mutating.ts +0 -65
- package/src/inject-is-restoring.ts +0 -52
- package/src/inject-mutation-state.ts +0 -125
- package/src/inject-mutation.ts +0 -169
- package/src/inject-queries.ts +0 -271
- package/src/inject-query-client.ts +0 -23
- package/src/inject-query.ts +0 -230
- package/src/mutation-options.ts +0 -60
- package/src/providers.ts +0 -372
- package/src/query-options.ts +0 -178
- package/src/signal-proxy.ts +0 -46
- package/src/types.ts +0 -309
- package/src/util/is-dev-mode/is-dev-mode.ts +0 -3
- /package/{dist/create-base-query.d.ts → create-base-query.d.ts} +0 -0
- /package/{dist/create-base-query.mjs → create-base-query.mjs} +0 -0
- /package/{dist/create-base-query.mjs.map → create-base-query.mjs.map} +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.mjs → index.mjs} +0 -0
- /package/{dist/index.mjs.map → index.mjs.map} +0 -0
- /package/{dist/infinite-query-options.d.ts → infinite-query-options.d.ts} +0 -0
- /package/{dist/infinite-query-options.mjs → infinite-query-options.mjs} +0 -0
- /package/{dist/infinite-query-options.mjs.map → infinite-query-options.mjs.map} +0 -0
- /package/{dist/inject-infinite-query.d.ts → inject-infinite-query.d.ts} +0 -0
- /package/{dist/inject-infinite-query.mjs → inject-infinite-query.mjs} +0 -0
- /package/{dist/inject-infinite-query.mjs.map → inject-infinite-query.mjs.map} +0 -0
- /package/{dist/inject-is-fetching.d.ts → inject-is-fetching.d.ts} +0 -0
- /package/{dist/inject-is-fetching.mjs → inject-is-fetching.mjs} +0 -0
- /package/{dist/inject-is-fetching.mjs.map → inject-is-fetching.mjs.map} +0 -0
- /package/{dist/inject-is-mutating.d.ts → inject-is-mutating.d.ts} +0 -0
- /package/{dist/inject-is-mutating.mjs → inject-is-mutating.mjs} +0 -0
- /package/{dist/inject-is-mutating.mjs.map → inject-is-mutating.mjs.map} +0 -0
- /package/{dist/inject-is-restoring.d.ts → inject-is-restoring.d.ts} +0 -0
- /package/{dist/inject-is-restoring.mjs → inject-is-restoring.mjs} +0 -0
- /package/{dist/inject-is-restoring.mjs.map → inject-is-restoring.mjs.map} +0 -0
- /package/{dist/inject-mutation-state.d.ts → inject-mutation-state.d.ts} +0 -0
- /package/{dist/inject-mutation-state.mjs → inject-mutation-state.mjs} +0 -0
- /package/{dist/inject-mutation-state.mjs.map → inject-mutation-state.mjs.map} +0 -0
- /package/{dist/inject-mutation.d.ts → inject-mutation.d.ts} +0 -0
- /package/{dist/inject-mutation.mjs → inject-mutation.mjs} +0 -0
- /package/{dist/inject-mutation.mjs.map → inject-mutation.mjs.map} +0 -0
- /package/{dist/inject-queries.d.ts → inject-queries.d.ts} +0 -0
- /package/{dist/inject-queries.mjs → inject-queries.mjs} +0 -0
- /package/{dist/inject-queries.mjs.map → inject-queries.mjs.map} +0 -0
- /package/{dist/inject-query-client.d.ts → inject-query-client.d.ts} +0 -0
- /package/{dist/inject-query-client.mjs → inject-query-client.mjs} +0 -0
- /package/{dist/inject-query-client.mjs.map → inject-query-client.mjs.map} +0 -0
- /package/{dist/inject-query.d.ts → inject-query.d.ts} +0 -0
- /package/{dist/inject-query.mjs → inject-query.mjs} +0 -0
- /package/{dist/inject-query.mjs.map → inject-query.mjs.map} +0 -0
- /package/{dist/mutation-options.d.ts → mutation-options.d.ts} +0 -0
- /package/{dist/mutation-options.mjs → mutation-options.mjs} +0 -0
- /package/{dist/mutation-options.mjs.map → mutation-options.mjs.map} +0 -0
- /package/{dist/providers.d.ts → providers.d.ts} +0 -0
- /package/{dist/providers.mjs → providers.mjs} +0 -0
- /package/{dist/providers.mjs.map → providers.mjs.map} +0 -0
- /package/{dist/query-options.d.ts → query-options.d.ts} +0 -0
- /package/{dist/query-options.mjs → query-options.mjs} +0 -0
- /package/{dist/query-options.mjs.map → query-options.mjs.map} +0 -0
- /package/{dist/signal-proxy.d.ts → signal-proxy.d.ts} +0 -0
- /package/{dist/signal-proxy.mjs → signal-proxy.mjs} +0 -0
- /package/{dist/signal-proxy.mjs.map → signal-proxy.mjs.map} +0 -0
- /package/{dist/types.d.ts → types.d.ts} +0 -0
- /package/{dist/util → util}/is-dev-mode/is-dev-mode.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/angular-query-experimental",
|
|
3
|
-
"version": "5.84.
|
|
3
|
+
"version": "5.84.1",
|
|
4
4
|
"description": "Signals for managing, caching and syncing asynchronous and remote data in Angular",
|
|
5
5
|
"author": "Arnoud de Vries",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,59 +27,23 @@
|
|
|
27
27
|
"tanstack"
|
|
28
28
|
],
|
|
29
29
|
"type": "module",
|
|
30
|
-
"types": "
|
|
31
|
-
"module": "
|
|
30
|
+
"types": "./index.d.ts",
|
|
31
|
+
"module": "./index.mjs",
|
|
32
32
|
"exports": {
|
|
33
33
|
".": {
|
|
34
34
|
"@tanstack/custom-condition": "./src/index.ts",
|
|
35
|
-
"types": "./
|
|
36
|
-
"default": "./
|
|
35
|
+
"types": "./index.d.ts",
|
|
36
|
+
"default": "./index.mjs"
|
|
37
37
|
},
|
|
38
38
|
"./package.json": "./package.json"
|
|
39
39
|
},
|
|
40
40
|
"sideEffects": false,
|
|
41
|
-
"files": [
|
|
42
|
-
"dist",
|
|
43
|
-
"src",
|
|
44
|
-
"!src/__tests__"
|
|
45
|
-
],
|
|
46
41
|
"dependencies": {
|
|
47
|
-
"@tanstack/query-
|
|
48
|
-
"@tanstack/query-
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@angular/common": "^20.0.0",
|
|
52
|
-
"@angular/compiler": "^20.0.0",
|
|
53
|
-
"@angular/core": "^20.0.0",
|
|
54
|
-
"@angular/platform-browser": "^20.0.0",
|
|
55
|
-
"eslint-plugin-jsdoc": "^50.5.0",
|
|
56
|
-
"npm-run-all2": "^5.0.0",
|
|
57
|
-
"vite-plugin-dts": "4.2.3",
|
|
58
|
-
"vite-plugin-externalize-deps": "^0.9.0",
|
|
59
|
-
"vite-tsconfig-paths": "^5.1.4",
|
|
60
|
-
"@tanstack/query-test-utils": "0.0.0"
|
|
42
|
+
"@tanstack/query-devtools": "5.84.0",
|
|
43
|
+
"@tanstack/query-core": "5.83.1"
|
|
61
44
|
},
|
|
62
45
|
"peerDependencies": {
|
|
63
46
|
"@angular/common": ">=16.0.0",
|
|
64
47
|
"@angular/core": ">=16.0.0"
|
|
65
|
-
},
|
|
66
|
-
"scripts": {
|
|
67
|
-
"clean": "premove ./build ./dist ./coverage ./dist-ts",
|
|
68
|
-
"compile": "tsc --build",
|
|
69
|
-
"test:eslint": "eslint ./src",
|
|
70
|
-
"test:types": "npm-run-all --serial test:types:*",
|
|
71
|
-
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js --build",
|
|
72
|
-
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js --build",
|
|
73
|
-
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js --build",
|
|
74
|
-
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js --build",
|
|
75
|
-
"test:types:ts54": "node ../../node_modules/typescript54/lib/tsc.js --build",
|
|
76
|
-
"test:types:ts55": "node ../../node_modules/typescript55/lib/tsc.js --build",
|
|
77
|
-
"test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js --build",
|
|
78
|
-
"test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js --build",
|
|
79
|
-
"test:types:tscurrent": "tsc --build",
|
|
80
|
-
"test:lib": "vitest",
|
|
81
|
-
"test:lib:dev": "pnpm run test:lib --watch",
|
|
82
|
-
"test:build": "pnpm pack && publint ./dist/*.tgz --strict && attw ./dist/*.tgz; premove ./dist/*.tgz",
|
|
83
|
-
"build": "vite build"
|
|
84
48
|
}
|
|
85
49
|
}
|
package/src/create-base-query.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NgZone,
|
|
3
|
-
VERSION,
|
|
4
|
-
computed,
|
|
5
|
-
effect,
|
|
6
|
-
inject,
|
|
7
|
-
signal,
|
|
8
|
-
untracked,
|
|
9
|
-
} from '@angular/core'
|
|
10
|
-
import {
|
|
11
|
-
QueryClient,
|
|
12
|
-
notifyManager,
|
|
13
|
-
shouldThrowError,
|
|
14
|
-
} from '@tanstack/query-core'
|
|
15
|
-
import { signalProxy } from './signal-proxy'
|
|
16
|
-
import { injectIsRestoring } from './inject-is-restoring'
|
|
17
|
-
import type {
|
|
18
|
-
QueryKey,
|
|
19
|
-
QueryObserver,
|
|
20
|
-
QueryObserverResult,
|
|
21
|
-
} from '@tanstack/query-core'
|
|
22
|
-
import type { CreateBaseQueryOptions } from './types'
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Base implementation for `injectQuery` and `injectInfiniteQuery`.
|
|
26
|
-
* @param optionsFn
|
|
27
|
-
* @param Observer
|
|
28
|
-
*/
|
|
29
|
-
export function createBaseQuery<
|
|
30
|
-
TQueryFnData,
|
|
31
|
-
TError,
|
|
32
|
-
TData,
|
|
33
|
-
TQueryData,
|
|
34
|
-
TQueryKey extends QueryKey,
|
|
35
|
-
>(
|
|
36
|
-
optionsFn: () => CreateBaseQueryOptions<
|
|
37
|
-
TQueryFnData,
|
|
38
|
-
TError,
|
|
39
|
-
TData,
|
|
40
|
-
TQueryData,
|
|
41
|
-
TQueryKey
|
|
42
|
-
>,
|
|
43
|
-
Observer: typeof QueryObserver,
|
|
44
|
-
) {
|
|
45
|
-
const ngZone = inject(NgZone)
|
|
46
|
-
const queryClient = inject(QueryClient)
|
|
47
|
-
const isRestoring = injectIsRestoring()
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Signal that has the default options from query client applied
|
|
51
|
-
* computed() is used so signals can be inserted into the options
|
|
52
|
-
* making it reactive. Wrapping options in a function ensures embedded expressions
|
|
53
|
-
* are preserved and can keep being applied after signal changes
|
|
54
|
-
*/
|
|
55
|
-
const defaultedOptionsSignal = computed(() => {
|
|
56
|
-
const defaultedOptions = queryClient.defaultQueryOptions(optionsFn())
|
|
57
|
-
defaultedOptions._optimisticResults = isRestoring()
|
|
58
|
-
? 'isRestoring'
|
|
59
|
-
: 'optimistic'
|
|
60
|
-
return defaultedOptions
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
const observerSignal = (() => {
|
|
64
|
-
let instance: QueryObserver<
|
|
65
|
-
TQueryFnData,
|
|
66
|
-
TError,
|
|
67
|
-
TData,
|
|
68
|
-
TQueryData,
|
|
69
|
-
TQueryKey
|
|
70
|
-
> | null = null
|
|
71
|
-
|
|
72
|
-
return computed(() => {
|
|
73
|
-
return (instance ||= new Observer(queryClient, defaultedOptionsSignal()))
|
|
74
|
-
})
|
|
75
|
-
})()
|
|
76
|
-
|
|
77
|
-
const optimisticResultSignal = computed(() =>
|
|
78
|
-
observerSignal().getOptimisticResult(defaultedOptionsSignal()),
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
const resultFromSubscriberSignal = signal<QueryObserverResult<
|
|
82
|
-
TData,
|
|
83
|
-
TError
|
|
84
|
-
> | null>(null)
|
|
85
|
-
|
|
86
|
-
effect(
|
|
87
|
-
(onCleanup) => {
|
|
88
|
-
const observer = observerSignal()
|
|
89
|
-
const defaultedOptions = defaultedOptionsSignal()
|
|
90
|
-
|
|
91
|
-
untracked(() => {
|
|
92
|
-
observer.setOptions(defaultedOptions)
|
|
93
|
-
})
|
|
94
|
-
onCleanup(() => {
|
|
95
|
-
ngZone.run(() => resultFromSubscriberSignal.set(null))
|
|
96
|
-
})
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
// Set allowSignalWrites to support Angular < v19
|
|
100
|
-
// Set to undefined to avoid warning on newer versions
|
|
101
|
-
allowSignalWrites: VERSION.major < '19' || undefined,
|
|
102
|
-
},
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
effect((onCleanup) => {
|
|
106
|
-
// observer.trackResult is not used as this optimization is not needed for Angular
|
|
107
|
-
const observer = observerSignal()
|
|
108
|
-
const unsubscribe = isRestoring()
|
|
109
|
-
? () => undefined
|
|
110
|
-
: untracked(() =>
|
|
111
|
-
ngZone.runOutsideAngular(() =>
|
|
112
|
-
observer.subscribe(
|
|
113
|
-
notifyManager.batchCalls((state) => {
|
|
114
|
-
ngZone.run(() => {
|
|
115
|
-
if (
|
|
116
|
-
state.isError &&
|
|
117
|
-
!state.isFetching &&
|
|
118
|
-
shouldThrowError(observer.options.throwOnError, [
|
|
119
|
-
state.error,
|
|
120
|
-
observer.getCurrentQuery(),
|
|
121
|
-
])
|
|
122
|
-
) {
|
|
123
|
-
ngZone.onError.emit(state.error)
|
|
124
|
-
throw state.error
|
|
125
|
-
}
|
|
126
|
-
resultFromSubscriberSignal.set(state)
|
|
127
|
-
})
|
|
128
|
-
}),
|
|
129
|
-
),
|
|
130
|
-
),
|
|
131
|
-
)
|
|
132
|
-
onCleanup(unsubscribe)
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
return signalProxy(
|
|
136
|
-
computed(() => {
|
|
137
|
-
const subscriberResult = resultFromSubscriberSignal()
|
|
138
|
-
const optimisticResult = optimisticResultSignal()
|
|
139
|
-
return subscriberResult ?? optimisticResult
|
|
140
|
-
}),
|
|
141
|
-
)
|
|
142
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
|
|
3
|
-
// Re-export core
|
|
4
|
-
export * from '@tanstack/query-core'
|
|
5
|
-
|
|
6
|
-
export * from './types'
|
|
7
|
-
|
|
8
|
-
export type {
|
|
9
|
-
DefinedInitialDataOptions,
|
|
10
|
-
UndefinedInitialDataOptions,
|
|
11
|
-
UnusedSkipTokenOptions,
|
|
12
|
-
} from './query-options'
|
|
13
|
-
export { queryOptions } from './query-options'
|
|
14
|
-
|
|
15
|
-
export type { CreateMutationOptions } from './mutation-options'
|
|
16
|
-
export { mutationOptions } from './mutation-options'
|
|
17
|
-
|
|
18
|
-
export type {
|
|
19
|
-
DefinedInitialDataInfiniteOptions,
|
|
20
|
-
UndefinedInitialDataInfiniteOptions,
|
|
21
|
-
UnusedSkipTokenInfiniteOptions,
|
|
22
|
-
} from './infinite-query-options'
|
|
23
|
-
export { infiniteQueryOptions } from './infinite-query-options'
|
|
24
|
-
|
|
25
|
-
export type { InjectInfiniteQueryOptions } from './inject-infinite-query'
|
|
26
|
-
export { injectInfiniteQuery } from './inject-infinite-query'
|
|
27
|
-
|
|
28
|
-
export type { InjectIsFetchingOptions } from './inject-is-fetching'
|
|
29
|
-
export { injectIsFetching } from './inject-is-fetching'
|
|
30
|
-
|
|
31
|
-
export type { InjectIsMutatingOptions } from './inject-is-mutating'
|
|
32
|
-
export { injectIsMutating } from './inject-is-mutating'
|
|
33
|
-
|
|
34
|
-
export { injectIsRestoring, provideIsRestoring } from './inject-is-restoring'
|
|
35
|
-
|
|
36
|
-
export type { InjectMutationOptions } from './inject-mutation'
|
|
37
|
-
export { injectMutation } from './inject-mutation'
|
|
38
|
-
|
|
39
|
-
export type { InjectMutationStateOptions } from './inject-mutation-state'
|
|
40
|
-
export { injectMutationState } from './inject-mutation-state'
|
|
41
|
-
|
|
42
|
-
export type { QueriesOptions, QueriesResults } from './inject-queries'
|
|
43
|
-
export { injectQueries } from './inject-queries'
|
|
44
|
-
|
|
45
|
-
export type { InjectQueryOptions } from './inject-query'
|
|
46
|
-
export { injectQuery } from './inject-query'
|
|
47
|
-
|
|
48
|
-
export { injectQueryClient } from './inject-query-client'
|
|
49
|
-
|
|
50
|
-
export type {
|
|
51
|
-
DeveloperToolsFeature,
|
|
52
|
-
DevtoolsOptions,
|
|
53
|
-
PersistQueryClientFeature,
|
|
54
|
-
QueryFeature,
|
|
55
|
-
QueryFeatureKind,
|
|
56
|
-
QueryFeatures,
|
|
57
|
-
} from './providers'
|
|
58
|
-
export {
|
|
59
|
-
provideQueryClient,
|
|
60
|
-
provideTanStackQuery,
|
|
61
|
-
queryFeature,
|
|
62
|
-
queryFeatures,
|
|
63
|
-
withDevtools,
|
|
64
|
-
} from './providers'
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DataTag,
|
|
3
|
-
DefaultError,
|
|
4
|
-
InfiniteData,
|
|
5
|
-
InitialDataFunction,
|
|
6
|
-
NonUndefinedGuard,
|
|
7
|
-
OmitKeyof,
|
|
8
|
-
QueryKey,
|
|
9
|
-
SkipToken,
|
|
10
|
-
} from '@tanstack/query-core'
|
|
11
|
-
import type { CreateInfiniteQueryOptions } from './types'
|
|
12
|
-
|
|
13
|
-
export type UndefinedInitialDataInfiniteOptions<
|
|
14
|
-
TQueryFnData,
|
|
15
|
-
TError = DefaultError,
|
|
16
|
-
TData = InfiniteData<TQueryFnData>,
|
|
17
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
18
|
-
TPageParam = unknown,
|
|
19
|
-
> = CreateInfiniteQueryOptions<
|
|
20
|
-
TQueryFnData,
|
|
21
|
-
TError,
|
|
22
|
-
TData,
|
|
23
|
-
TQueryKey,
|
|
24
|
-
TPageParam
|
|
25
|
-
> & {
|
|
26
|
-
initialData?:
|
|
27
|
-
| undefined
|
|
28
|
-
| NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
29
|
-
| InitialDataFunction<
|
|
30
|
-
NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
31
|
-
>
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type UnusedSkipTokenInfiniteOptions<
|
|
35
|
-
TQueryFnData,
|
|
36
|
-
TError = DefaultError,
|
|
37
|
-
TData = InfiniteData<TQueryFnData>,
|
|
38
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
39
|
-
TPageParam = unknown,
|
|
40
|
-
> = OmitKeyof<
|
|
41
|
-
CreateInfiniteQueryOptions<
|
|
42
|
-
TQueryFnData,
|
|
43
|
-
TError,
|
|
44
|
-
TData,
|
|
45
|
-
TQueryKey,
|
|
46
|
-
TPageParam
|
|
47
|
-
>,
|
|
48
|
-
'queryFn'
|
|
49
|
-
> & {
|
|
50
|
-
queryFn?: Exclude<
|
|
51
|
-
CreateInfiniteQueryOptions<
|
|
52
|
-
TQueryFnData,
|
|
53
|
-
TError,
|
|
54
|
-
TData,
|
|
55
|
-
TQueryKey,
|
|
56
|
-
TPageParam
|
|
57
|
-
>['queryFn'],
|
|
58
|
-
SkipToken | undefined
|
|
59
|
-
>
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type DefinedInitialDataInfiniteOptions<
|
|
63
|
-
TQueryFnData,
|
|
64
|
-
TError = DefaultError,
|
|
65
|
-
TData = InfiniteData<TQueryFnData>,
|
|
66
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
67
|
-
TPageParam = unknown,
|
|
68
|
-
> = CreateInfiniteQueryOptions<
|
|
69
|
-
TQueryFnData,
|
|
70
|
-
TError,
|
|
71
|
-
TData,
|
|
72
|
-
TQueryKey,
|
|
73
|
-
TPageParam
|
|
74
|
-
> & {
|
|
75
|
-
initialData:
|
|
76
|
-
| NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
77
|
-
| (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)
|
|
78
|
-
| undefined
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Allows to share and re-use infinite query options in a type-safe way.
|
|
83
|
-
*
|
|
84
|
-
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
85
|
-
* @param options - The infinite query options to tag with the type from `queryFn`.
|
|
86
|
-
* @returns The tagged infinite query options.
|
|
87
|
-
* @public
|
|
88
|
-
*/
|
|
89
|
-
export function infiniteQueryOptions<
|
|
90
|
-
TQueryFnData,
|
|
91
|
-
TError = DefaultError,
|
|
92
|
-
TData = InfiniteData<TQueryFnData>,
|
|
93
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
94
|
-
TPageParam = unknown,
|
|
95
|
-
>(
|
|
96
|
-
options: DefinedInitialDataInfiniteOptions<
|
|
97
|
-
TQueryFnData,
|
|
98
|
-
TError,
|
|
99
|
-
TData,
|
|
100
|
-
TQueryKey,
|
|
101
|
-
TPageParam
|
|
102
|
-
>,
|
|
103
|
-
): DefinedInitialDataInfiniteOptions<
|
|
104
|
-
TQueryFnData,
|
|
105
|
-
TError,
|
|
106
|
-
TData,
|
|
107
|
-
TQueryKey,
|
|
108
|
-
TPageParam
|
|
109
|
-
> & {
|
|
110
|
-
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Allows to share and re-use infinite query options in a type-safe way.
|
|
115
|
-
*
|
|
116
|
-
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
117
|
-
* @param options - The infinite query options to tag with the type from `queryFn`.
|
|
118
|
-
* @returns The tagged infinite query options.
|
|
119
|
-
* @public
|
|
120
|
-
*/
|
|
121
|
-
export function infiniteQueryOptions<
|
|
122
|
-
TQueryFnData,
|
|
123
|
-
TError = DefaultError,
|
|
124
|
-
TData = InfiniteData<TQueryFnData>,
|
|
125
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
126
|
-
TPageParam = unknown,
|
|
127
|
-
>(
|
|
128
|
-
options: UnusedSkipTokenInfiniteOptions<
|
|
129
|
-
TQueryFnData,
|
|
130
|
-
TError,
|
|
131
|
-
TData,
|
|
132
|
-
TQueryKey,
|
|
133
|
-
TPageParam
|
|
134
|
-
>,
|
|
135
|
-
): UnusedSkipTokenInfiniteOptions<
|
|
136
|
-
TQueryFnData,
|
|
137
|
-
TError,
|
|
138
|
-
TData,
|
|
139
|
-
TQueryKey,
|
|
140
|
-
TPageParam
|
|
141
|
-
> & {
|
|
142
|
-
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Allows to share and re-use infinite query options in a type-safe way.
|
|
147
|
-
*
|
|
148
|
-
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
149
|
-
* @param options - The infinite query options to tag with the type from `queryFn`.
|
|
150
|
-
* @returns The tagged infinite query options.
|
|
151
|
-
* @public
|
|
152
|
-
*/
|
|
153
|
-
export function infiniteQueryOptions<
|
|
154
|
-
TQueryFnData,
|
|
155
|
-
TError = DefaultError,
|
|
156
|
-
TData = InfiniteData<TQueryFnData>,
|
|
157
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
158
|
-
TPageParam = unknown,
|
|
159
|
-
>(
|
|
160
|
-
options: UndefinedInitialDataInfiniteOptions<
|
|
161
|
-
TQueryFnData,
|
|
162
|
-
TError,
|
|
163
|
-
TData,
|
|
164
|
-
TQueryKey,
|
|
165
|
-
TPageParam
|
|
166
|
-
>,
|
|
167
|
-
): UndefinedInitialDataInfiniteOptions<
|
|
168
|
-
TQueryFnData,
|
|
169
|
-
TError,
|
|
170
|
-
TData,
|
|
171
|
-
TQueryKey,
|
|
172
|
-
TPageParam
|
|
173
|
-
> & {
|
|
174
|
-
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Allows to share and re-use infinite query options in a type-safe way.
|
|
179
|
-
*
|
|
180
|
-
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
181
|
-
* @param options - The infinite query options to tag with the type from `queryFn`.
|
|
182
|
-
* @returns The tagged infinite query options.
|
|
183
|
-
* @public
|
|
184
|
-
*/
|
|
185
|
-
export function infiniteQueryOptions(options: unknown) {
|
|
186
|
-
return options
|
|
187
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { InfiniteQueryObserver } from '@tanstack/query-core'
|
|
2
|
-
import {
|
|
3
|
-
Injector,
|
|
4
|
-
assertInInjectionContext,
|
|
5
|
-
inject,
|
|
6
|
-
runInInjectionContext,
|
|
7
|
-
} from '@angular/core'
|
|
8
|
-
import { createBaseQuery } from './create-base-query'
|
|
9
|
-
import type {
|
|
10
|
-
DefaultError,
|
|
11
|
-
InfiniteData,
|
|
12
|
-
QueryKey,
|
|
13
|
-
QueryObserver,
|
|
14
|
-
} from '@tanstack/query-core'
|
|
15
|
-
import type {
|
|
16
|
-
CreateInfiniteQueryOptions,
|
|
17
|
-
CreateInfiniteQueryResult,
|
|
18
|
-
DefinedCreateInfiniteQueryResult,
|
|
19
|
-
} from './types'
|
|
20
|
-
import type {
|
|
21
|
-
DefinedInitialDataInfiniteOptions,
|
|
22
|
-
UndefinedInitialDataInfiniteOptions,
|
|
23
|
-
} from './infinite-query-options'
|
|
24
|
-
|
|
25
|
-
export interface InjectInfiniteQueryOptions {
|
|
26
|
-
/**
|
|
27
|
-
* The `Injector` in which to create the infinite query.
|
|
28
|
-
*
|
|
29
|
-
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
30
|
-
*/
|
|
31
|
-
injector?: Injector
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
36
|
-
* Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
|
|
37
|
-
* @param injectInfiniteQueryFn - A function that returns infinite query options.
|
|
38
|
-
* @param options - Additional configuration.
|
|
39
|
-
* @returns The infinite query result.
|
|
40
|
-
* @public
|
|
41
|
-
*/
|
|
42
|
-
export function injectInfiniteQuery<
|
|
43
|
-
TQueryFnData,
|
|
44
|
-
TError = DefaultError,
|
|
45
|
-
TData = InfiniteData<TQueryFnData>,
|
|
46
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
47
|
-
TPageParam = unknown,
|
|
48
|
-
>(
|
|
49
|
-
injectInfiniteQueryFn: () => DefinedInitialDataInfiniteOptions<
|
|
50
|
-
TQueryFnData,
|
|
51
|
-
TError,
|
|
52
|
-
TData,
|
|
53
|
-
TQueryKey,
|
|
54
|
-
TPageParam
|
|
55
|
-
>,
|
|
56
|
-
options?: InjectInfiniteQueryOptions,
|
|
57
|
-
): DefinedCreateInfiniteQueryResult<TData, TError>
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
61
|
-
* Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
|
|
62
|
-
* @param injectInfiniteQueryFn - A function that returns infinite query options.
|
|
63
|
-
* @param options - Additional configuration.
|
|
64
|
-
* @returns The infinite query result.
|
|
65
|
-
* @public
|
|
66
|
-
*/
|
|
67
|
-
export function injectInfiniteQuery<
|
|
68
|
-
TQueryFnData,
|
|
69
|
-
TError = DefaultError,
|
|
70
|
-
TData = InfiniteData<TQueryFnData>,
|
|
71
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
72
|
-
TPageParam = unknown,
|
|
73
|
-
>(
|
|
74
|
-
injectInfiniteQueryFn: () => UndefinedInitialDataInfiniteOptions<
|
|
75
|
-
TQueryFnData,
|
|
76
|
-
TError,
|
|
77
|
-
TData,
|
|
78
|
-
TQueryKey,
|
|
79
|
-
TPageParam
|
|
80
|
-
>,
|
|
81
|
-
options?: InjectInfiniteQueryOptions,
|
|
82
|
-
): CreateInfiniteQueryResult<TData, TError>
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
86
|
-
* Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
|
|
87
|
-
* @param injectInfiniteQueryFn - A function that returns infinite query options.
|
|
88
|
-
* @param options - Additional configuration.
|
|
89
|
-
* @returns The infinite query result.
|
|
90
|
-
* @public
|
|
91
|
-
*/
|
|
92
|
-
export function injectInfiniteQuery<
|
|
93
|
-
TQueryFnData,
|
|
94
|
-
TError = DefaultError,
|
|
95
|
-
TData = InfiniteData<TQueryFnData>,
|
|
96
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
97
|
-
TPageParam = unknown,
|
|
98
|
-
>(
|
|
99
|
-
injectInfiniteQueryFn: () => CreateInfiniteQueryOptions<
|
|
100
|
-
TQueryFnData,
|
|
101
|
-
TError,
|
|
102
|
-
TData,
|
|
103
|
-
TQueryKey,
|
|
104
|
-
TPageParam
|
|
105
|
-
>,
|
|
106
|
-
options?: InjectInfiniteQueryOptions,
|
|
107
|
-
): CreateInfiniteQueryResult<TData, TError>
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
111
|
-
* Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
|
|
112
|
-
* @param injectInfiniteQueryFn - A function that returns infinite query options.
|
|
113
|
-
* @param options - Additional configuration.
|
|
114
|
-
* @returns The infinite query result.
|
|
115
|
-
* @public
|
|
116
|
-
*/
|
|
117
|
-
export function injectInfiniteQuery(
|
|
118
|
-
injectInfiniteQueryFn: () => CreateInfiniteQueryOptions,
|
|
119
|
-
options?: InjectInfiniteQueryOptions,
|
|
120
|
-
) {
|
|
121
|
-
!options?.injector && assertInInjectionContext(injectInfiniteQuery)
|
|
122
|
-
const injector = options?.injector ?? inject(Injector)
|
|
123
|
-
return runInInjectionContext(injector, () =>
|
|
124
|
-
createBaseQuery(
|
|
125
|
-
injectInfiniteQueryFn,
|
|
126
|
-
InfiniteQueryObserver as typeof QueryObserver,
|
|
127
|
-
),
|
|
128
|
-
)
|
|
129
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DestroyRef,
|
|
3
|
-
Injector,
|
|
4
|
-
NgZone,
|
|
5
|
-
assertInInjectionContext,
|
|
6
|
-
inject,
|
|
7
|
-
signal,
|
|
8
|
-
} from '@angular/core'
|
|
9
|
-
import { QueryClient, notifyManager } from '@tanstack/query-core'
|
|
10
|
-
import type { QueryFilters } from '@tanstack/query-core'
|
|
11
|
-
import type { Signal } from '@angular/core'
|
|
12
|
-
|
|
13
|
-
export interface InjectIsFetchingOptions {
|
|
14
|
-
/**
|
|
15
|
-
* The `Injector` in which to create the isFetching signal.
|
|
16
|
-
*
|
|
17
|
-
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
18
|
-
*/
|
|
19
|
-
injector?: Injector
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Injects a signal that tracks the number of queries that your application is loading or
|
|
24
|
-
* fetching in the background.
|
|
25
|
-
*
|
|
26
|
-
* Can be used for app-wide loading indicators
|
|
27
|
-
* @param filters - The filters to apply to the query.
|
|
28
|
-
* @param options - Additional configuration
|
|
29
|
-
* @returns signal with number of loading or fetching queries.
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export function injectIsFetching(
|
|
33
|
-
filters?: QueryFilters,
|
|
34
|
-
options?: InjectIsFetchingOptions,
|
|
35
|
-
): Signal<number> {
|
|
36
|
-
!options?.injector && assertInInjectionContext(injectIsFetching)
|
|
37
|
-
const injector = options?.injector ?? inject(Injector)
|
|
38
|
-
const destroyRef = injector.get(DestroyRef)
|
|
39
|
-
const ngZone = injector.get(NgZone)
|
|
40
|
-
const queryClient = injector.get(QueryClient)
|
|
41
|
-
|
|
42
|
-
const cache = queryClient.getQueryCache()
|
|
43
|
-
// isFetching is the prev value initialized on mount *
|
|
44
|
-
let isFetching = queryClient.isFetching(filters)
|
|
45
|
-
|
|
46
|
-
const result = signal(isFetching)
|
|
47
|
-
|
|
48
|
-
const unsubscribe = ngZone.runOutsideAngular(() =>
|
|
49
|
-
cache.subscribe(
|
|
50
|
-
notifyManager.batchCalls(() => {
|
|
51
|
-
const newIsFetching = queryClient.isFetching(filters)
|
|
52
|
-
if (isFetching !== newIsFetching) {
|
|
53
|
-
// * and update with each change
|
|
54
|
-
isFetching = newIsFetching
|
|
55
|
-
ngZone.run(() => {
|
|
56
|
-
result.set(isFetching)
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
}),
|
|
60
|
-
),
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
destroyRef.onDestroy(unsubscribe)
|
|
64
|
-
|
|
65
|
-
return result
|
|
66
|
-
}
|