@tanstack/angular-query-experimental 5.60.0 → 5.60.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.
Files changed (53) hide show
  1. package/build/{rollup.d.ts → index.d.ts} +278 -356
  2. package/build/index.js +616 -0
  3. package/build/index.js.map +1 -0
  4. package/package.json +12 -15
  5. package/src/create-base-query.ts +119 -0
  6. package/src/index.ts +28 -0
  7. package/src/infinite-query-options.ts +125 -0
  8. package/src/inject-infinite-query.ts +119 -0
  9. package/src/inject-is-fetching.ts +50 -0
  10. package/src/inject-is-mutating.ts +49 -0
  11. package/src/inject-mutation-state.ts +99 -0
  12. package/src/inject-mutation.ts +122 -0
  13. package/src/inject-queries.ts +243 -0
  14. package/src/inject-query-client.ts +27 -0
  15. package/src/inject-query.ts +207 -0
  16. package/src/providers.ts +344 -0
  17. package/src/query-options.ts +125 -0
  18. package/src/signal-proxy.ts +46 -0
  19. package/src/test-setup.ts +12 -0
  20. package/src/types.ts +328 -0
  21. package/src/util/assert-injector/assert-injector.test.ts +74 -0
  22. package/src/util/assert-injector/assert-injector.ts +81 -0
  23. package/src/util/create-injection-token/create-injection-token.test.ts +32 -0
  24. package/src/util/create-injection-token/create-injection-token.ts +183 -0
  25. package/src/util/index.ts +13 -0
  26. package/src/util/is-dev-mode/is-dev-mode.ts +3 -0
  27. package/src/util/lazy-init/lazy-init.ts +34 -0
  28. package/src/util/lazy-signal-initializer/lazy-signal-initializer.ts +23 -0
  29. package/build/README.md +0 -133
  30. package/build/esm2022/create-base-query.mjs +0 -62
  31. package/build/esm2022/index.mjs +0 -16
  32. package/build/esm2022/infinite-query-options.mjs +0 -12
  33. package/build/esm2022/inject-infinite-query.mjs +0 -15
  34. package/build/esm2022/inject-is-fetching.mjs +0 -38
  35. package/build/esm2022/inject-is-mutating.mjs +0 -37
  36. package/build/esm2022/inject-mutation-state.mjs +0 -47
  37. package/build/esm2022/inject-mutation.mjs +0 -51
  38. package/build/esm2022/inject-queries.mjs +0 -33
  39. package/build/esm2022/inject-query-client.mjs +0 -23
  40. package/build/esm2022/inject-query.mjs +0 -44
  41. package/build/esm2022/providers.mjs +0 -206
  42. package/build/esm2022/query-options.mjs +0 -26
  43. package/build/esm2022/signal-proxy.mjs +0 -38
  44. package/build/esm2022/tanstack-angular-query-experimental.mjs +0 -5
  45. package/build/esm2022/types.mjs +0 -3
  46. package/build/esm2022/util/assert-injector/assert-injector.mjs +0 -21
  47. package/build/esm2022/util/create-injection-token/create-injection-token.mjs +0 -61
  48. package/build/esm2022/util/index.mjs +0 -9
  49. package/build/esm2022/util/is-dev-mode/is-dev-mode.mjs +0 -3
  50. package/build/esm2022/util/lazy-init/lazy-init.mjs +0 -31
  51. package/build/esm2022/util/lazy-signal-initializer/lazy-signal-initializer.mjs +0 -14
  52. package/build/fesm2022/tanstack-angular-query-experimental.mjs +0 -738
  53. package/build/fesm2022/tanstack-angular-query-experimental.mjs.map +0 -1
@@ -0,0 +1,50 @@
1
+ import { DestroyRef, NgZone, inject, signal } from '@angular/core'
2
+ import { notifyManager } from '@tanstack/query-core'
3
+ import { assertInjector } from './util/assert-injector/assert-injector'
4
+ import { injectQueryClient } from './inject-query-client'
5
+ import type { QueryFilters } from '@tanstack/query-core'
6
+ import type { Injector, Signal } from '@angular/core'
7
+
8
+ /**
9
+ * Injects a signal that tracks the number of queries that your application is loading or
10
+ * fetching in the background.
11
+ *
12
+ * Can be used for app-wide loading indicators
13
+ * @param filters - The filters to apply to the query.
14
+ * @param injector - The Angular injector to use.
15
+ * @returns signal with number of loading or fetching queries.
16
+ * @public
17
+ */
18
+ export function injectIsFetching(
19
+ filters?: QueryFilters,
20
+ injector?: Injector,
21
+ ): Signal<number> {
22
+ return assertInjector(injectIsFetching, injector, () => {
23
+ const queryClient = injectQueryClient()
24
+ const destroyRef = inject(DestroyRef)
25
+ const ngZone = inject(NgZone)
26
+
27
+ const cache = queryClient.getQueryCache()
28
+ // isFetching is the prev value initialized on mount *
29
+ let isFetching = queryClient.isFetching(filters)
30
+
31
+ const result = signal(isFetching)
32
+
33
+ const unsubscribe = cache.subscribe(
34
+ notifyManager.batchCalls(() => {
35
+ const newIsFetching = queryClient.isFetching(filters)
36
+ if (isFetching !== newIsFetching) {
37
+ // * and update with each change
38
+ isFetching = newIsFetching
39
+ ngZone.run(() => {
40
+ result.set(isFetching)
41
+ })
42
+ }
43
+ }),
44
+ )
45
+
46
+ destroyRef.onDestroy(unsubscribe)
47
+
48
+ return result
49
+ })
50
+ }
@@ -0,0 +1,49 @@
1
+ import { DestroyRef, NgZone, inject, signal } from '@angular/core'
2
+ import { notifyManager } from '@tanstack/query-core'
3
+ import { assertInjector } from './util/assert-injector/assert-injector'
4
+ import { injectQueryClient } from './inject-query-client'
5
+ import type { MutationFilters } from '@tanstack/query-core'
6
+ import type { Injector, Signal } from '@angular/core'
7
+
8
+ /**
9
+ * Injects a signal that tracks the number of mutations that your application is fetching.
10
+ *
11
+ * Can be used for app-wide loading indicators
12
+ * @param filters - The filters to apply to the query.
13
+ * @param injector - The Angular injector to use.
14
+ * @returns signal with number of fetching mutations.
15
+ * @public
16
+ */
17
+ export function injectIsMutating(
18
+ filters?: MutationFilters,
19
+ injector?: Injector,
20
+ ): Signal<number> {
21
+ return assertInjector(injectIsMutating, injector, () => {
22
+ const queryClient = injectQueryClient()
23
+ const destroyRef = inject(DestroyRef)
24
+ const ngZone = inject(NgZone)
25
+
26
+ const cache = queryClient.getMutationCache()
27
+ // isMutating is the prev value initialized on mount *
28
+ let isMutating = queryClient.isMutating(filters)
29
+
30
+ const result = signal(isMutating)
31
+
32
+ const unsubscribe = cache.subscribe(
33
+ notifyManager.batchCalls(() => {
34
+ const newIsMutating = queryClient.isMutating(filters)
35
+ if (isMutating !== newIsMutating) {
36
+ // * and update with each change
37
+ isMutating = newIsMutating
38
+ ngZone.run(() => {
39
+ result.set(isMutating)
40
+ })
41
+ }
42
+ }),
43
+ )
44
+
45
+ destroyRef.onDestroy(unsubscribe)
46
+
47
+ return result
48
+ })
49
+ }
@@ -0,0 +1,99 @@
1
+ import {
2
+ DestroyRef,
3
+ NgZone,
4
+ effect,
5
+ inject,
6
+ signal,
7
+ untracked,
8
+ } from '@angular/core'
9
+ import { notifyManager, replaceEqualDeep } from '@tanstack/query-core'
10
+ import { assertInjector } from './util/assert-injector/assert-injector'
11
+ import { injectQueryClient } from './inject-query-client'
12
+ import { lazySignalInitializer } from './util/lazy-signal-initializer/lazy-signal-initializer'
13
+ import type { Injector, Signal } from '@angular/core'
14
+ import type {
15
+ Mutation,
16
+ MutationCache,
17
+ MutationFilters,
18
+ MutationState,
19
+ } from '@tanstack/query-core'
20
+
21
+ type MutationStateOptions<TResult = MutationState> = {
22
+ filters?: MutationFilters
23
+ select?: (mutation: Mutation) => TResult
24
+ }
25
+
26
+ function getResult<TResult = MutationState>(
27
+ mutationCache: MutationCache,
28
+ options: MutationStateOptions<TResult>,
29
+ ): Array<TResult> {
30
+ return mutationCache
31
+ .findAll(options.filters)
32
+ .map(
33
+ (mutation): TResult =>
34
+ (options.select ? options.select(mutation) : mutation.state) as TResult,
35
+ )
36
+ }
37
+
38
+ /**
39
+ * @public
40
+ */
41
+ export interface InjectMutationStateOptions {
42
+ injector?: Injector
43
+ }
44
+
45
+ /**
46
+ * Injects a signal that tracks the state of all mutations.
47
+ * @param mutationStateOptionsFn - A function that returns mutation state options.
48
+ * @param options - The Angular injector to use.
49
+ * @returns The signal that tracks the state of all mutations.
50
+ * @public
51
+ */
52
+ export function injectMutationState<TResult = MutationState>(
53
+ mutationStateOptionsFn: () => MutationStateOptions<TResult> = () => ({}),
54
+ options?: InjectMutationStateOptions,
55
+ ): Signal<Array<TResult>> {
56
+ return assertInjector(injectMutationState, options?.injector, () => {
57
+ const destroyRef = inject(DestroyRef)
58
+ const queryClient = injectQueryClient()
59
+ const ngZone = inject(NgZone)
60
+
61
+ const mutationCache = queryClient.getMutationCache()
62
+
63
+ return lazySignalInitializer((injector) => {
64
+ const result = signal<Array<TResult>>(
65
+ getResult(mutationCache, mutationStateOptionsFn()),
66
+ )
67
+
68
+ effect(
69
+ () => {
70
+ const mutationStateOptions = mutationStateOptionsFn()
71
+ untracked(() => {
72
+ // Setting the signal from an effect because it's both 'computed' from options()
73
+ // and needs to be set imperatively in the mutationCache listener.
74
+ result.set(getResult(mutationCache, mutationStateOptions))
75
+ })
76
+ },
77
+ { injector },
78
+ )
79
+
80
+ const unsubscribe = mutationCache.subscribe(
81
+ notifyManager.batchCalls(() => {
82
+ const nextResult = replaceEqualDeep(
83
+ result(),
84
+ getResult(mutationCache, mutationStateOptionsFn()),
85
+ )
86
+ if (result() !== nextResult) {
87
+ ngZone.run(() => {
88
+ result.set(nextResult)
89
+ })
90
+ }
91
+ }),
92
+ )
93
+
94
+ destroyRef.onDestroy(unsubscribe)
95
+
96
+ return result
97
+ })
98
+ })
99
+ }
@@ -0,0 +1,122 @@
1
+ import {
2
+ DestroyRef,
3
+ Injector,
4
+ NgZone,
5
+ computed,
6
+ effect,
7
+ inject,
8
+ runInInjectionContext,
9
+ signal,
10
+ } from '@angular/core'
11
+ import { MutationObserver, notifyManager } from '@tanstack/query-core'
12
+ import { assertInjector } from './util/assert-injector/assert-injector'
13
+ import { signalProxy } from './signal-proxy'
14
+ import { injectQueryClient } from './inject-query-client'
15
+ import { noop, shouldThrowError } from './util'
16
+
17
+ import { lazyInit } from './util/lazy-init/lazy-init'
18
+ import type {
19
+ DefaultError,
20
+ MutationObserverResult,
21
+ QueryClient,
22
+ } from '@tanstack/query-core'
23
+ import type {
24
+ CreateMutateFunction,
25
+ CreateMutationOptions,
26
+ CreateMutationResult,
27
+ } from './types'
28
+
29
+ /**
30
+ * Injects a mutation: an imperative function that can be invoked which typically performs server side effects.
31
+ *
32
+ * Unlike queries, mutations are not run automatically.
33
+ * @param optionsFn - A function that returns mutation options.
34
+ * @param injector - The Angular injector to use.
35
+ * @returns The mutation.
36
+ * @public
37
+ */
38
+ export function injectMutation<
39
+ TData = unknown,
40
+ TError = DefaultError,
41
+ TVariables = void,
42
+ TContext = unknown,
43
+ >(
44
+ optionsFn: (
45
+ client: QueryClient,
46
+ ) => CreateMutationOptions<TData, TError, TVariables, TContext>,
47
+ injector?: Injector,
48
+ ): CreateMutationResult<TData, TError, TVariables, TContext> {
49
+ return assertInjector(injectMutation, injector, () => {
50
+ const queryClient = injectQueryClient()
51
+ const currentInjector = inject(Injector)
52
+ const destroyRef = inject(DestroyRef)
53
+ const ngZone = inject(NgZone)
54
+
55
+ return lazyInit(() =>
56
+ runInInjectionContext(currentInjector, () => {
57
+ const observer = new MutationObserver<
58
+ TData,
59
+ TError,
60
+ TVariables,
61
+ TContext
62
+ >(queryClient, optionsFn(queryClient))
63
+ const mutate: CreateMutateFunction<
64
+ TData,
65
+ TError,
66
+ TVariables,
67
+ TContext
68
+ > = (variables, mutateOptions) => {
69
+ observer.mutate(variables, mutateOptions).catch(noop)
70
+ }
71
+
72
+ effect(() => {
73
+ observer.setOptions(
74
+ runInInjectionContext(currentInjector, () =>
75
+ optionsFn(queryClient),
76
+ ),
77
+ )
78
+ })
79
+
80
+ const result = signal(observer.getCurrentResult())
81
+
82
+ const unsubscribe = observer.subscribe(
83
+ notifyManager.batchCalls(
84
+ (
85
+ state: MutationObserverResult<
86
+ TData,
87
+ TError,
88
+ TVariables,
89
+ TContext
90
+ >,
91
+ ) => {
92
+ ngZone.run(() => {
93
+ if (
94
+ state.isError &&
95
+ shouldThrowError(observer.options.throwOnError, [state.error])
96
+ ) {
97
+ throw state.error
98
+ }
99
+ result.set(state)
100
+ })
101
+ },
102
+ ),
103
+ )
104
+
105
+ destroyRef.onDestroy(unsubscribe)
106
+
107
+ const resultSignal = computed(() => ({
108
+ ...result(),
109
+ mutate,
110
+ mutateAsync: result().mutate,
111
+ }))
112
+
113
+ return signalProxy(resultSignal) as unknown as CreateMutationResult<
114
+ TData,
115
+ TError,
116
+ TVariables,
117
+ TContext
118
+ >
119
+ }),
120
+ )
121
+ })
122
+ }
@@ -0,0 +1,243 @@
1
+ import { QueriesObserver, notifyManager } from '@tanstack/query-core'
2
+ import { DestroyRef, computed, effect, inject, signal } from '@angular/core'
3
+ import { assertInjector } from './util/assert-injector/assert-injector'
4
+ import { injectQueryClient } from './inject-query-client'
5
+ import type { Injector, Signal } from '@angular/core'
6
+ import type {
7
+ DefaultError,
8
+ OmitKeyof,
9
+ QueriesObserverOptions,
10
+ QueriesPlaceholderDataFunction,
11
+ QueryFunction,
12
+ QueryKey,
13
+ QueryObserverOptions,
14
+ QueryObserverResult,
15
+ ThrowOnError,
16
+ } from '@tanstack/query-core'
17
+
18
+ // This defines the `CreateQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.
19
+ // `placeholderData` function does not have a parameter
20
+ type QueryObserverOptionsForCreateQueries<
21
+ TQueryFnData = unknown,
22
+ TError = DefaultError,
23
+ TData = TQueryFnData,
24
+ TQueryKey extends QueryKey = QueryKey,
25
+ > = OmitKeyof<
26
+ QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,
27
+ 'placeholderData'
28
+ > & {
29
+ placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>
30
+ }
31
+
32
+ // Avoid TS depth-limit error in case of large array literal
33
+ type MAXIMUM_DEPTH = 20
34
+
35
+ // Widen the type of the symbol to enable type inference even if skipToken is not immutable.
36
+ type SkipTokenForUseQueries = symbol
37
+
38
+ type GetOptions<T> =
39
+ // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }
40
+ T extends {
41
+ queryFnData: infer TQueryFnData
42
+ error?: infer TError
43
+ data: infer TData
44
+ }
45
+ ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData>
46
+ : T extends { queryFnData: infer TQueryFnData; error?: infer TError }
47
+ ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError>
48
+ : T extends { data: infer TData; error?: infer TError }
49
+ ? QueryObserverOptionsForCreateQueries<unknown, TError, TData>
50
+ : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]
51
+ T extends [infer TQueryFnData, infer TError, infer TData]
52
+ ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData>
53
+ : T extends [infer TQueryFnData, infer TError]
54
+ ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError>
55
+ : T extends [infer TQueryFnData]
56
+ ? QueryObserverOptionsForCreateQueries<TQueryFnData>
57
+ : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided
58
+ T extends {
59
+ queryFn?:
60
+ | QueryFunction<infer TQueryFnData, infer TQueryKey>
61
+ | SkipTokenForUseQueries
62
+ select: (data: any) => infer TData
63
+ throwOnError?: ThrowOnError<any, infer TError, any, any>
64
+ }
65
+ ? QueryObserverOptionsForCreateQueries<
66
+ TQueryFnData,
67
+ unknown extends TError ? DefaultError : TError,
68
+ unknown extends TData ? TQueryFnData : TData,
69
+ TQueryKey
70
+ >
71
+ : // Fallback
72
+ QueryObserverOptionsForCreateQueries
73
+
74
+ type GetResults<T> =
75
+ // Part 1: responsible for mapping explicit type parameter to function result, if object
76
+ T extends { queryFnData: any; error?: infer TError; data: infer TData }
77
+ ? QueryObserverResult<TData, TError>
78
+ : T extends { queryFnData: infer TQueryFnData; error?: infer TError }
79
+ ? QueryObserverResult<TQueryFnData, TError>
80
+ : T extends { data: infer TData; error?: infer TError }
81
+ ? QueryObserverResult<TData, TError>
82
+ : // Part 2: responsible for mapping explicit type parameter to function result, if tuple
83
+ T extends [any, infer TError, infer TData]
84
+ ? QueryObserverResult<TData, TError>
85
+ : T extends [infer TQueryFnData, infer TError]
86
+ ? QueryObserverResult<TQueryFnData, TError>
87
+ : T extends [infer TQueryFnData]
88
+ ? QueryObserverResult<TQueryFnData>
89
+ : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided
90
+ T extends {
91
+ queryFn?:
92
+ | QueryFunction<infer TQueryFnData, any>
93
+ | SkipTokenForUseQueries
94
+ select: (data: any) => infer TData
95
+ throwOnError?: ThrowOnError<any, infer TError, any, any>
96
+ }
97
+ ? QueryObserverResult<
98
+ unknown extends TData ? TQueryFnData : TData,
99
+ unknown extends TError ? DefaultError : TError
100
+ >
101
+ : // Fallback
102
+ QueryObserverResult
103
+
104
+ /**
105
+ * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
106
+ * @public
107
+ */
108
+ export type QueriesOptions<
109
+ T extends Array<any>,
110
+ TResult extends Array<any> = [],
111
+ TDepth extends ReadonlyArray<number> = [],
112
+ > = TDepth['length'] extends MAXIMUM_DEPTH
113
+ ? Array<QueryObserverOptionsForCreateQueries>
114
+ : T extends []
115
+ ? []
116
+ : T extends [infer Head]
117
+ ? [...TResult, GetOptions<Head>]
118
+ : T extends [infer Head, ...infer Tail]
119
+ ? QueriesOptions<
120
+ [...Tail],
121
+ [...TResult, GetOptions<Head>],
122
+ [...TDepth, 1]
123
+ >
124
+ : ReadonlyArray<unknown> extends T
125
+ ? T
126
+ : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogenous type!
127
+ // use this to infer the param types in the case of Array.map() argument
128
+ T extends Array<
129
+ QueryObserverOptionsForCreateQueries<
130
+ infer TQueryFnData,
131
+ infer TError,
132
+ infer TData,
133
+ infer TQueryKey
134
+ >
135
+ >
136
+ ? Array<
137
+ QueryObserverOptionsForCreateQueries<
138
+ TQueryFnData,
139
+ TError,
140
+ TData,
141
+ TQueryKey
142
+ >
143
+ >
144
+ : // Fallback
145
+ Array<QueryObserverOptionsForCreateQueries>
146
+
147
+ /**
148
+ * QueriesResults reducer recursively maps type param to results
149
+ * @public
150
+ */
151
+ export type QueriesResults<
152
+ T extends Array<any>,
153
+ TResult extends Array<any> = [],
154
+ TDepth extends ReadonlyArray<number> = [],
155
+ > = TDepth['length'] extends MAXIMUM_DEPTH
156
+ ? Array<QueryObserverResult>
157
+ : T extends []
158
+ ? []
159
+ : T extends [infer Head]
160
+ ? [...TResult, GetResults<Head>]
161
+ : T extends [infer Head, ...infer Tail]
162
+ ? QueriesResults<
163
+ [...Tail],
164
+ [...TResult, GetResults<Head>],
165
+ [...TDepth, 1]
166
+ >
167
+ : T extends Array<
168
+ QueryObserverOptionsForCreateQueries<
169
+ infer TQueryFnData,
170
+ infer TError,
171
+ infer TData,
172
+ any
173
+ >
174
+ >
175
+ ? // Dynamic-size (homogenous) CreateQueryOptions array: map directly to array of results
176
+ Array<
177
+ QueryObserverResult<
178
+ unknown extends TData ? TQueryFnData : TData,
179
+ unknown extends TError ? DefaultError : TError
180
+ >
181
+ >
182
+ : // Fallback
183
+ Array<QueryObserverResult>
184
+
185
+ /**
186
+ * @public
187
+ */
188
+ export function injectQueries<
189
+ T extends Array<any>,
190
+ TCombinedResult = QueriesResults<T>,
191
+ >(
192
+ {
193
+ queries,
194
+ ...options
195
+ }: {
196
+ queries: Signal<[...QueriesOptions<T>]>
197
+ combine?: (result: QueriesResults<T>) => TCombinedResult
198
+ },
199
+ injector?: Injector,
200
+ ): Signal<TCombinedResult> {
201
+ return assertInjector(injectQueries, injector, () => {
202
+ const queryClient = injectQueryClient()
203
+ const destroyRef = inject(DestroyRef)
204
+
205
+ const defaultedQueries = computed(() => {
206
+ return queries().map((opts) => {
207
+ const defaultedOptions = queryClient.defaultQueryOptions(opts)
208
+ // Make sure the results are already in fetching state before subscribing or updating options
209
+ defaultedOptions._optimisticResults = 'optimistic'
210
+
211
+ return defaultedOptions as QueryObserverOptions
212
+ })
213
+ })
214
+
215
+ const observer = new QueriesObserver<TCombinedResult>(
216
+ queryClient,
217
+ defaultedQueries(),
218
+ options as QueriesObserverOptions<TCombinedResult>,
219
+ )
220
+
221
+ // Do not notify on updates because of changes in the options because
222
+ // these changes should already be reflected in the optimistic result.
223
+ effect(() => {
224
+ observer.setQueries(
225
+ defaultedQueries(),
226
+ options as QueriesObserverOptions<TCombinedResult>,
227
+ { listeners: false },
228
+ )
229
+ })
230
+
231
+ const [, getCombinedResult] = observer.getOptimisticResult(
232
+ defaultedQueries(),
233
+ (options as QueriesObserverOptions<TCombinedResult>).combine,
234
+ )
235
+
236
+ const result = signal(getCombinedResult() as any)
237
+
238
+ const unsubscribe = observer.subscribe(notifyManager.batchCalls(result.set))
239
+ destroyRef.onDestroy(unsubscribe)
240
+
241
+ return result
242
+ })
243
+ }
@@ -0,0 +1,27 @@
1
+ import { createNoopInjectionToken } from './util/create-injection-token/create-injection-token'
2
+ import type { QueryClient } from '@tanstack/query-core'
3
+
4
+ const tokens = createNoopInjectionToken<QueryClient>('QueryClientToken')
5
+
6
+ /**
7
+ * Injects the `QueryClient` instance into the component or service.
8
+ *
9
+ * **Example**
10
+ * ```ts
11
+ * const queryClient = injectQueryClient();
12
+ * ```
13
+ * @returns The `QueryClient` instance.
14
+ * @public
15
+ */
16
+ export const injectQueryClient = tokens[0]
17
+
18
+ /**
19
+ * Usually {@link provideTanStackQuery} is used once to set up TanStack Query and the
20
+ * {@link https://tanstack.com/query/latest/docs/reference/QueryClient|QueryClient}
21
+ * for the entire application. You can use `provideQueryClient` to provide a
22
+ * different `QueryClient` instance for a part of the application.
23
+ * @public
24
+ */
25
+ export const provideQueryClient = tokens[1]
26
+
27
+ export const QUERY_CLIENT = tokens[2]