@tanstack/angular-query-experimental 5.72.1 → 5.72.3
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/index.d.ts +79 -30
- package/build/index.mjs +26 -23
- package/build/index.mjs.map +1 -1
- package/package.json +3 -4
- package/src/inject-infinite-query.ts +35 -19
- package/src/inject-is-fetching.ts +12 -3
- package/src/inject-is-mutating.ts +12 -3
- package/src/inject-mutation-state.ts +14 -4
- package/src/inject-mutation.ts +24 -10
- package/src/inject-queries.ts +1 -0
- package/src/inject-query.ts +32 -18
- package/src/providers.ts +4 -4
- package/src/util/assert-injector/assert-injector.ts +12 -10
package/build/index.d.ts
CHANGED
|
@@ -236,64 +236,99 @@ declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData
|
|
|
236
236
|
/**
|
|
237
237
|
* Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
238
238
|
* Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
|
|
239
|
-
* @param
|
|
240
|
-
* @param
|
|
239
|
+
* @param injectInfiniteQueryFn - A function that returns infinite query options.
|
|
240
|
+
* @param options - Additional configuration.
|
|
241
241
|
* @returns The infinite query result.
|
|
242
242
|
* @public
|
|
243
243
|
*/
|
|
244
|
-
declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(
|
|
244
|
+
declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): DefinedCreateInfiniteQueryResult<TData, TError>;
|
|
245
245
|
/**
|
|
246
246
|
* Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
247
247
|
* Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
|
|
248
|
-
* @param
|
|
249
|
-
* @param
|
|
248
|
+
* @param injectInfiniteQueryFn - A function that returns infinite query options.
|
|
249
|
+
* @param options - Additional configuration.
|
|
250
250
|
* @returns The infinite query result.
|
|
251
251
|
* @public
|
|
252
252
|
*/
|
|
253
|
-
declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(
|
|
253
|
+
declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): CreateInfiniteQueryResult<TData, TError>;
|
|
254
254
|
/**
|
|
255
255
|
* Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
256
256
|
* Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
|
|
257
|
-
* @param
|
|
258
|
-
* @param
|
|
257
|
+
* @param injectInfiniteQueryFn - A function that returns infinite query options.
|
|
258
|
+
* @param options - Additional configuration.
|
|
259
259
|
* @returns The infinite query result.
|
|
260
260
|
* @public
|
|
261
261
|
*/
|
|
262
|
-
declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(
|
|
262
|
+
declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): CreateInfiniteQueryResult<TData, TError>;
|
|
263
|
+
interface InjectInfiniteQueryOptions {
|
|
264
|
+
/**
|
|
265
|
+
* The `Injector` in which to create the infinite query.
|
|
266
|
+
*
|
|
267
|
+
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
268
|
+
*/
|
|
269
|
+
injector?: Injector;
|
|
270
|
+
}
|
|
271
|
+
interface InjectInfiniteQueryOptions {
|
|
272
|
+
injector?: Injector;
|
|
273
|
+
}
|
|
263
274
|
|
|
275
|
+
interface InjectIsFetchingOptions {
|
|
276
|
+
/**
|
|
277
|
+
* The `Injector` in which to create the isFetching signal.
|
|
278
|
+
*
|
|
279
|
+
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
280
|
+
*/
|
|
281
|
+
injector?: Injector;
|
|
282
|
+
}
|
|
264
283
|
/**
|
|
265
284
|
* Injects a signal that tracks the number of queries that your application is loading or
|
|
266
285
|
* fetching in the background.
|
|
267
286
|
*
|
|
268
287
|
* Can be used for app-wide loading indicators
|
|
269
288
|
* @param filters - The filters to apply to the query.
|
|
270
|
-
* @param
|
|
289
|
+
* @param options - Additional configuration
|
|
271
290
|
* @returns signal with number of loading or fetching queries.
|
|
272
291
|
* @public
|
|
273
292
|
*/
|
|
274
|
-
declare function injectIsFetching(filters?: QueryFilters,
|
|
293
|
+
declare function injectIsFetching(filters?: QueryFilters, options?: InjectIsFetchingOptions): Signal<number>;
|
|
275
294
|
|
|
295
|
+
interface InjectIsMutatingOptions {
|
|
296
|
+
/**
|
|
297
|
+
* The `Injector` in which to create the isMutating signal.
|
|
298
|
+
*
|
|
299
|
+
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
300
|
+
*/
|
|
301
|
+
injector?: Injector;
|
|
302
|
+
}
|
|
276
303
|
/**
|
|
277
304
|
* Injects a signal that tracks the number of mutations that your application is fetching.
|
|
278
305
|
*
|
|
279
306
|
* Can be used for app-wide loading indicators
|
|
280
307
|
* @param filters - The filters to apply to the query.
|
|
281
|
-
* @param
|
|
308
|
+
* @param options - Additional configuration
|
|
282
309
|
* @returns signal with number of fetching mutations.
|
|
283
310
|
* @public
|
|
284
311
|
*/
|
|
285
|
-
declare function injectIsMutating(filters?: MutationFilters,
|
|
312
|
+
declare function injectIsMutating(filters?: MutationFilters, options?: InjectIsMutatingOptions): Signal<number>;
|
|
286
313
|
|
|
314
|
+
interface InjectMutationOptions {
|
|
315
|
+
/**
|
|
316
|
+
* The `Injector` in which to create the mutation.
|
|
317
|
+
*
|
|
318
|
+
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
319
|
+
*/
|
|
320
|
+
injector?: Injector;
|
|
321
|
+
}
|
|
287
322
|
/**
|
|
288
323
|
* Injects a mutation: an imperative function that can be invoked which typically performs server side effects.
|
|
289
324
|
*
|
|
290
325
|
* Unlike queries, mutations are not run automatically.
|
|
291
|
-
* @param
|
|
292
|
-
* @param
|
|
326
|
+
* @param injectMutationFn - A function that returns mutation options.
|
|
327
|
+
* @param options - Additional configuration
|
|
293
328
|
* @returns The mutation.
|
|
294
329
|
* @public
|
|
295
330
|
*/
|
|
296
|
-
declare function injectMutation<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(
|
|
331
|
+
declare function injectMutation<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(injectMutationFn: () => CreateMutationOptions<TData, TError, TVariables, TContext>, options?: InjectMutationOptions): CreateMutationResult<TData, TError, TVariables, TContext>;
|
|
297
332
|
|
|
298
333
|
type MutationStateOptions<TResult = MutationState> = {
|
|
299
334
|
filters?: MutationFilters;
|
|
@@ -303,16 +338,21 @@ type MutationStateOptions<TResult = MutationState> = {
|
|
|
303
338
|
* @public
|
|
304
339
|
*/
|
|
305
340
|
interface InjectMutationStateOptions {
|
|
341
|
+
/**
|
|
342
|
+
* The `Injector` in which to create the mutation state signal.
|
|
343
|
+
*
|
|
344
|
+
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
345
|
+
*/
|
|
306
346
|
injector?: Injector;
|
|
307
347
|
}
|
|
308
348
|
/**
|
|
309
349
|
* Injects a signal that tracks the state of all mutations.
|
|
310
|
-
* @param
|
|
350
|
+
* @param injectMutationStateFn - A function that returns mutation state options.
|
|
311
351
|
* @param options - The Angular injector to use.
|
|
312
352
|
* @returns The signal that tracks the state of all mutations.
|
|
313
353
|
* @public
|
|
314
354
|
*/
|
|
315
|
-
declare function injectMutationState<TResult = MutationState>(
|
|
355
|
+
declare function injectMutationState<TResult = MutationState>(injectMutationStateFn?: () => MutationStateOptions<TResult>, options?: InjectMutationStateOptions): Signal<Array<TResult>>;
|
|
316
356
|
|
|
317
357
|
type QueryObserverOptionsForCreateQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, 'placeholderData'> & {
|
|
318
358
|
placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
|
|
@@ -380,6 +420,7 @@ type QueriesResults<T extends Array<any>, TResult extends Array<any> = [], TDept
|
|
|
380
420
|
* @param root0.queries
|
|
381
421
|
* @param root0.combine
|
|
382
422
|
* @param injector
|
|
423
|
+
* @param injector
|
|
383
424
|
* @public
|
|
384
425
|
*/
|
|
385
426
|
declare function injectQueries<T extends Array<any>, TCombinedResult = QueriesResults<T>>({ queries, ...options }: {
|
|
@@ -387,6 +428,14 @@ declare function injectQueries<T extends Array<any>, TCombinedResult = QueriesRe
|
|
|
387
428
|
combine?: (result: QueriesResults<T>) => TCombinedResult;
|
|
388
429
|
}, injector?: Injector): Signal<TCombinedResult>;
|
|
389
430
|
|
|
431
|
+
interface InjectQueryOptions {
|
|
432
|
+
/**
|
|
433
|
+
* The `Injector` in which to create the query.
|
|
434
|
+
*
|
|
435
|
+
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
436
|
+
*/
|
|
437
|
+
injector?: Injector;
|
|
438
|
+
}
|
|
390
439
|
/**
|
|
391
440
|
* Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
392
441
|
*
|
|
@@ -418,13 +467,13 @@ declare function injectQueries<T extends Array<any>, TCombinedResult = QueriesRe
|
|
|
418
467
|
* }))
|
|
419
468
|
* }
|
|
420
469
|
* ```
|
|
421
|
-
* @param
|
|
422
|
-
* @param
|
|
470
|
+
* @param injectQueryFn - A function that returns query options.
|
|
471
|
+
* @param options - Additional configuration
|
|
423
472
|
* @returns The query result.
|
|
424
473
|
* @public
|
|
425
474
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
426
475
|
*/
|
|
427
|
-
declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(
|
|
476
|
+
declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(injectQueryFn: () => DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): DefinedCreateQueryResult<TData, TError>;
|
|
428
477
|
/**
|
|
429
478
|
* Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
430
479
|
*
|
|
@@ -456,13 +505,13 @@ declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TDat
|
|
|
456
505
|
* }))
|
|
457
506
|
* }
|
|
458
507
|
* ```
|
|
459
|
-
* @param
|
|
460
|
-
* @param
|
|
508
|
+
* @param injectQueryFn - A function that returns query options.
|
|
509
|
+
* @param options - Additional configuration
|
|
461
510
|
* @returns The query result.
|
|
462
511
|
* @public
|
|
463
512
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
464
513
|
*/
|
|
465
|
-
declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(
|
|
514
|
+
declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(injectQueryFn: () => UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
|
|
466
515
|
/**
|
|
467
516
|
* Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
468
517
|
*
|
|
@@ -494,13 +543,13 @@ declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TDat
|
|
|
494
543
|
* }))
|
|
495
544
|
* }
|
|
496
545
|
* ```
|
|
497
|
-
* @param
|
|
498
|
-
* @param
|
|
546
|
+
* @param injectQueryFn - A function that returns query options.
|
|
547
|
+
* @param options - Additional configuration
|
|
499
548
|
* @returns The query result.
|
|
500
549
|
* @public
|
|
501
550
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
502
551
|
*/
|
|
503
|
-
declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(
|
|
552
|
+
declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(injectQueryFn: () => CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
|
|
504
553
|
|
|
505
554
|
/**
|
|
506
555
|
* Injects a `QueryClient` instance and allows passing a custom injector.
|
|
@@ -693,13 +742,13 @@ interface DevtoolsOptions {
|
|
|
693
742
|
* If you need more control over when devtools are loaded, you can use the `loadDevtools` option. This is particularly useful if you want to load devtools based on environment configurations. For instance, you might have a test environment running in production mode but still require devtools to be available.
|
|
694
743
|
*
|
|
695
744
|
* If you need more control over where devtools are rendered, consider `injectDevtoolsPanel`. This allows rendering devtools inside your own devtools for example.
|
|
696
|
-
* @param
|
|
745
|
+
* @param withDevtoolsFn - A function that returns `DevtoolsOptions`.
|
|
697
746
|
* @returns A set of providers for use with `provideTanStackQuery`.
|
|
698
747
|
* @public
|
|
699
748
|
* @see {@link provideTanStackQuery}
|
|
700
749
|
* @see {@link DevtoolsOptions}
|
|
701
750
|
*/
|
|
702
|
-
declare function withDevtools(
|
|
751
|
+
declare function withDevtools(withDevtoolsFn?: () => DevtoolsOptions): DeveloperToolsFeature;
|
|
703
752
|
/**
|
|
704
753
|
* A type alias that represents all Query features available for use with `provideTanStackQuery`.
|
|
705
754
|
* Features can be enabled by adding special functions to the `provideTanStackQuery` call.
|
|
@@ -712,4 +761,4 @@ type QueryFeatures = DeveloperToolsFeature;
|
|
|
712
761
|
declare const queryFeatures: readonly ["DeveloperTools"];
|
|
713
762
|
type QueryFeatureKind = (typeof queryFeatures)[number];
|
|
714
763
|
|
|
715
|
-
export { type BaseMutationNarrowing, type BaseQueryNarrowing, type CreateBaseMutationResult, type CreateBaseQueryOptions, type CreateBaseQueryResult, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreateMutateAsyncFunction, type CreateMutateFunction, type CreateMutationOptions, type CreateMutationResult, type CreateQueryOptions, type CreateQueryResult, type DefinedCreateInfiniteQueryResult, type DefinedCreateQueryResult, type DefinedInitialDataInfiniteOptions, type DefinedInitialDataOptions, type DeveloperToolsFeature, type DevtoolsOptions, type InjectMutationStateOptions, type NonUndefinedGuard, type QueriesOptions, type QueriesResults, type QueryFeature, type QueryFeatureKind, type QueryFeatures, type UndefinedInitialDataInfiniteOptions, type UndefinedInitialDataOptions, infiniteQueryOptions, injectInfiniteQuery, injectIsFetching, injectIsMutating, injectMutation, injectMutationState, injectQueries, injectQuery, injectQueryClient, mutationOptions, provideAngularQuery, provideQueryClient, provideTanStackQuery, queryFeatures, queryOptions, withDevtools };
|
|
764
|
+
export { type BaseMutationNarrowing, type BaseQueryNarrowing, type CreateBaseMutationResult, type CreateBaseQueryOptions, type CreateBaseQueryResult, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreateMutateAsyncFunction, type CreateMutateFunction, type CreateMutationOptions, type CreateMutationResult, type CreateQueryOptions, type CreateQueryResult, type DefinedCreateInfiniteQueryResult, type DefinedCreateQueryResult, type DefinedInitialDataInfiniteOptions, type DefinedInitialDataOptions, type DeveloperToolsFeature, type DevtoolsOptions, type InjectInfiniteQueryOptions, type InjectIsFetchingOptions, type InjectIsMutatingOptions, type InjectMutationOptions, type InjectMutationStateOptions, type InjectQueryOptions, type NonUndefinedGuard, type QueriesOptions, type QueriesResults, type QueryFeature, type QueryFeatureKind, type QueryFeatures, type UndefinedInitialDataInfiniteOptions, type UndefinedInitialDataOptions, infiniteQueryOptions, injectInfiniteQuery, injectIsFetching, injectIsMutating, injectMutation, injectMutationState, injectQueries, injectQuery, injectQueryClient, mutationOptions, provideAngularQuery, provideQueryClient, provideTanStackQuery, queryFeatures, queryOptions, withDevtools };
|
package/build/index.mjs
CHANGED
|
@@ -153,19 +153,22 @@ function assertInjector(fn, injector, runner) {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
// src/inject-infinite-query.ts
|
|
156
|
-
function injectInfiniteQuery(
|
|
156
|
+
function injectInfiniteQuery(injectInfiniteQueryFn, options) {
|
|
157
157
|
return assertInjector(
|
|
158
158
|
injectInfiniteQuery,
|
|
159
|
-
injector,
|
|
160
|
-
() => createBaseQuery(
|
|
159
|
+
options?.injector,
|
|
160
|
+
() => createBaseQuery(
|
|
161
|
+
injectInfiniteQueryFn,
|
|
162
|
+
InfiniteQueryObserver
|
|
163
|
+
)
|
|
161
164
|
);
|
|
162
165
|
}
|
|
163
166
|
|
|
164
167
|
// src/inject-is-fetching.ts
|
|
165
168
|
import { DestroyRef as DestroyRef2, NgZone as NgZone2, inject as inject3, signal as signal2 } from "@angular/core";
|
|
166
169
|
import { QueryClient as QueryClient2, notifyManager as notifyManager2 } from "@tanstack/query-core";
|
|
167
|
-
function injectIsFetching(filters,
|
|
168
|
-
return assertInjector(injectIsFetching, injector, () => {
|
|
170
|
+
function injectIsFetching(filters, options) {
|
|
171
|
+
return assertInjector(injectIsFetching, options?.injector, () => {
|
|
169
172
|
const destroyRef = inject3(DestroyRef2);
|
|
170
173
|
const ngZone = inject3(NgZone2);
|
|
171
174
|
const queryClient = inject3(QueryClient2);
|
|
@@ -193,8 +196,8 @@ function injectIsFetching(filters, injector) {
|
|
|
193
196
|
// src/inject-is-mutating.ts
|
|
194
197
|
import { DestroyRef as DestroyRef3, NgZone as NgZone3, inject as inject4, signal as signal3 } from "@angular/core";
|
|
195
198
|
import { QueryClient as QueryClient3, notifyManager as notifyManager3 } from "@tanstack/query-core";
|
|
196
|
-
function injectIsMutating(filters,
|
|
197
|
-
return assertInjector(injectIsMutating, injector, () => {
|
|
199
|
+
function injectIsMutating(filters, options) {
|
|
200
|
+
return assertInjector(injectIsMutating, options?.injector, () => {
|
|
198
201
|
const destroyRef = inject4(DestroyRef3);
|
|
199
202
|
const ngZone = inject4(NgZone3);
|
|
200
203
|
const queryClient = inject4(QueryClient3);
|
|
@@ -234,12 +237,12 @@ import {
|
|
|
234
237
|
QueryClient as QueryClient4,
|
|
235
238
|
notifyManager as notifyManager4
|
|
236
239
|
} from "@tanstack/query-core";
|
|
237
|
-
function injectMutation(
|
|
238
|
-
return assertInjector(injectMutation, injector, () => {
|
|
240
|
+
function injectMutation(injectMutationFn, options) {
|
|
241
|
+
return assertInjector(injectMutation, options?.injector, () => {
|
|
239
242
|
const destroyRef = inject5(DestroyRef4);
|
|
240
243
|
const ngZone = inject5(NgZone4);
|
|
241
244
|
const queryClient = inject5(QueryClient4);
|
|
242
|
-
const optionsSignal = computed3(
|
|
245
|
+
const optionsSignal = computed3(injectMutationFn);
|
|
243
246
|
const observerSignal = (() => {
|
|
244
247
|
let instance = null;
|
|
245
248
|
return computed3(() => {
|
|
@@ -260,13 +263,13 @@ function injectMutation(optionsFn, injector) {
|
|
|
260
263
|
effect2(
|
|
261
264
|
() => {
|
|
262
265
|
const observer = observerSignal();
|
|
263
|
-
const
|
|
266
|
+
const observerOptions = optionsSignal();
|
|
264
267
|
untracked3(() => {
|
|
265
|
-
observer.setOptions(
|
|
268
|
+
observer.setOptions(observerOptions);
|
|
266
269
|
});
|
|
267
270
|
},
|
|
268
271
|
{
|
|
269
|
-
injector
|
|
272
|
+
injector: options?.injector
|
|
270
273
|
}
|
|
271
274
|
);
|
|
272
275
|
effect2(
|
|
@@ -292,7 +295,7 @@ function injectMutation(optionsFn, injector) {
|
|
|
292
295
|
});
|
|
293
296
|
},
|
|
294
297
|
{
|
|
295
|
-
injector
|
|
298
|
+
injector: options?.injector
|
|
296
299
|
}
|
|
297
300
|
);
|
|
298
301
|
const resultSignal = computed3(() => {
|
|
@@ -321,7 +324,7 @@ function getResult(mutationCache, options) {
|
|
|
321
324
|
(mutation) => options.select ? options.select(mutation) : mutation.state
|
|
322
325
|
);
|
|
323
326
|
}
|
|
324
|
-
function injectMutationState(
|
|
327
|
+
function injectMutationState(injectMutationStateFn = () => ({}), options) {
|
|
325
328
|
return assertInjector(injectMutationState, options?.injector, () => {
|
|
326
329
|
const destroyRef = inject6(DestroyRef5);
|
|
327
330
|
const ngZone = inject6(NgZone5);
|
|
@@ -329,7 +332,7 @@ function injectMutationState(mutationStateOptionsFn = () => ({}), options) {
|
|
|
329
332
|
const mutationCache = queryClient.getMutationCache();
|
|
330
333
|
const resultFromOptionsSignal = computed4(() => {
|
|
331
334
|
return [
|
|
332
|
-
getResult(mutationCache,
|
|
335
|
+
getResult(mutationCache, injectMutationStateFn()),
|
|
333
336
|
performance.now()
|
|
334
337
|
];
|
|
335
338
|
});
|
|
@@ -347,7 +350,7 @@ function injectMutationState(mutationStateOptionsFn = () => ({}), options) {
|
|
|
347
350
|
const [lastResult] = effectiveResultSignal();
|
|
348
351
|
const nextResult = replaceEqualDeep(
|
|
349
352
|
lastResult,
|
|
350
|
-
getResult(mutationCache,
|
|
353
|
+
getResult(mutationCache, injectMutationStateFn())
|
|
351
354
|
);
|
|
352
355
|
if (lastResult !== nextResult) {
|
|
353
356
|
ngZone.run(() => {
|
|
@@ -417,11 +420,11 @@ function injectQueries({
|
|
|
417
420
|
|
|
418
421
|
// src/inject-query.ts
|
|
419
422
|
import { QueryObserver } from "@tanstack/query-core";
|
|
420
|
-
function injectQuery(
|
|
423
|
+
function injectQuery(injectQueryFn, options) {
|
|
421
424
|
return assertInjector(
|
|
422
425
|
injectQuery,
|
|
423
|
-
injector,
|
|
424
|
-
() => createBaseQuery(
|
|
426
|
+
options?.injector,
|
|
427
|
+
() => createBaseQuery(injectQueryFn, QueryObserver)
|
|
425
428
|
);
|
|
426
429
|
}
|
|
427
430
|
|
|
@@ -473,9 +476,9 @@ function provideAngularQuery(queryClient) {
|
|
|
473
476
|
function queryFeature(kind, providers) {
|
|
474
477
|
return { \u0275kind: kind, \u0275providers: providers };
|
|
475
478
|
}
|
|
476
|
-
function withDevtools(
|
|
479
|
+
function withDevtools(withDevtoolsFn) {
|
|
477
480
|
let providers = [];
|
|
478
|
-
if (!isDevMode() && !
|
|
481
|
+
if (!isDevMode() && !withDevtoolsFn) {
|
|
479
482
|
providers = [];
|
|
480
483
|
} else {
|
|
481
484
|
providers = [
|
|
@@ -489,7 +492,7 @@ function withDevtools(optionsFn) {
|
|
|
489
492
|
optional: true
|
|
490
493
|
});
|
|
491
494
|
const destroyRef = inject9(DestroyRef7);
|
|
492
|
-
const options = computed6(() =>
|
|
495
|
+
const options = computed6(() => withDevtoolsFn?.() ?? {});
|
|
493
496
|
let devtools = null;
|
|
494
497
|
let el = null;
|
|
495
498
|
const shouldLoadToolsSignal = computed6(() => {
|