@tanstack/angular-query-experimental 5.74.0 → 5.74.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.
- package/build/index.d.ts +8 -11
- package/build/index.mjs +211 -186
- package/build/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/inject-infinite-query.ts +9 -7
- package/src/inject-is-fetching.ts +34 -28
- package/src/inject-is-mutating.ts +34 -28
- package/src/inject-is-restoring.ts +3 -3
- package/src/inject-mutation-state.ts +61 -55
- package/src/inject-mutation.ts +108 -114
- package/src/inject-queries.ts +6 -3
- package/src/inject-query.ts +8 -3
- package/src/util/assert-injector/assert-injector.test.ts +0 -78
- package/src/util/assert-injector/assert-injector.ts +0 -83
package/build/index.d.ts
CHANGED
|
@@ -233,6 +233,14 @@ declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData
|
|
|
233
233
|
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>>;
|
|
234
234
|
};
|
|
235
235
|
|
|
236
|
+
interface InjectInfiniteQueryOptions {
|
|
237
|
+
/**
|
|
238
|
+
* The `Injector` in which to create the infinite query.
|
|
239
|
+
*
|
|
240
|
+
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
241
|
+
*/
|
|
242
|
+
injector?: Injector;
|
|
243
|
+
}
|
|
236
244
|
/**
|
|
237
245
|
* Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
238
246
|
* Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
|
|
@@ -260,17 +268,6 @@ declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData
|
|
|
260
268
|
* @public
|
|
261
269
|
*/
|
|
262
270
|
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
|
-
}
|
|
274
271
|
|
|
275
272
|
interface InjectIsFetchingOptions {
|
|
276
273
|
/**
|
package/build/index.mjs
CHANGED
|
@@ -18,6 +18,12 @@ function infiniteQueryOptions(options) {
|
|
|
18
18
|
|
|
19
19
|
// src/inject-infinite-query.ts
|
|
20
20
|
import { InfiniteQueryObserver } from "@tanstack/query-core";
|
|
21
|
+
import {
|
|
22
|
+
Injector as Injector2,
|
|
23
|
+
assertInInjectionContext as assertInInjectionContext2,
|
|
24
|
+
inject as inject3,
|
|
25
|
+
runInInjectionContext
|
|
26
|
+
} from "@angular/core";
|
|
21
27
|
|
|
22
28
|
// src/create-base-query.ts
|
|
23
29
|
import {
|
|
@@ -76,19 +82,19 @@ import {
|
|
|
76
82
|
computed as computed2,
|
|
77
83
|
inject
|
|
78
84
|
} from "@angular/core";
|
|
79
|
-
var
|
|
85
|
+
var IS_RESTORING = new InjectionToken("");
|
|
80
86
|
function injectIsRestoring(options) {
|
|
81
87
|
!options?.injector && assertInInjectionContext(injectIsRestoring);
|
|
82
88
|
const injector = options?.injector ?? inject(Injector);
|
|
83
89
|
return injector.get(
|
|
84
|
-
|
|
90
|
+
IS_RESTORING,
|
|
85
91
|
computed2(() => false),
|
|
86
92
|
{ optional: true }
|
|
87
93
|
);
|
|
88
94
|
}
|
|
89
95
|
function provideIsRestoring(isRestoring) {
|
|
90
96
|
return {
|
|
91
|
-
provide:
|
|
97
|
+
provide: IS_RESTORING,
|
|
92
98
|
useValue: isRestoring
|
|
93
99
|
};
|
|
94
100
|
}
|
|
@@ -161,25 +167,12 @@ function createBaseQuery(optionsFn, Observer) {
|
|
|
161
167
|
);
|
|
162
168
|
}
|
|
163
169
|
|
|
164
|
-
// src/util/assert-injector/assert-injector.ts
|
|
165
|
-
import {
|
|
166
|
-
Injector as Injector2,
|
|
167
|
-
assertInInjectionContext as assertInInjectionContext2,
|
|
168
|
-
inject as inject3,
|
|
169
|
-
runInInjectionContext
|
|
170
|
-
} from "@angular/core";
|
|
171
|
-
function assertInjector(fn, injector, runner) {
|
|
172
|
-
!injector && assertInInjectionContext2(fn);
|
|
173
|
-
const assertedInjector = injector ?? inject3(Injector2);
|
|
174
|
-
if (!runner) return assertedInjector;
|
|
175
|
-
return runInInjectionContext(assertedInjector, runner);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
170
|
// src/inject-infinite-query.ts
|
|
179
171
|
function injectInfiniteQuery(injectInfiniteQueryFn, options) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
172
|
+
!options?.injector && assertInInjectionContext2(injectInfiniteQuery);
|
|
173
|
+
const injector = options?.injector ?? inject3(Injector2);
|
|
174
|
+
return runInInjectionContext(
|
|
175
|
+
injector,
|
|
183
176
|
() => createBaseQuery(
|
|
184
177
|
injectInfiniteQueryFn,
|
|
185
178
|
InfiniteQueryObserver
|
|
@@ -188,67 +181,83 @@ function injectInfiniteQuery(injectInfiniteQueryFn, options) {
|
|
|
188
181
|
}
|
|
189
182
|
|
|
190
183
|
// src/inject-is-fetching.ts
|
|
191
|
-
import {
|
|
184
|
+
import {
|
|
185
|
+
DestroyRef,
|
|
186
|
+
Injector as Injector3,
|
|
187
|
+
NgZone as NgZone2,
|
|
188
|
+
assertInInjectionContext as assertInInjectionContext3,
|
|
189
|
+
inject as inject4,
|
|
190
|
+
signal as signal2
|
|
191
|
+
} from "@angular/core";
|
|
192
192
|
import { QueryClient as QueryClient2, notifyManager as notifyManager2 } from "@tanstack/query-core";
|
|
193
193
|
function injectIsFetching(filters, options) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
)
|
|
213
|
-
)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
194
|
+
!options?.injector && assertInInjectionContext3(injectIsFetching);
|
|
195
|
+
const injector = options?.injector ?? inject4(Injector3);
|
|
196
|
+
const destroyRef = injector.get(DestroyRef);
|
|
197
|
+
const ngZone = injector.get(NgZone2);
|
|
198
|
+
const queryClient = injector.get(QueryClient2);
|
|
199
|
+
const cache = queryClient.getQueryCache();
|
|
200
|
+
let isFetching = queryClient.isFetching(filters);
|
|
201
|
+
const result = signal2(isFetching);
|
|
202
|
+
const unsubscribe = ngZone.runOutsideAngular(
|
|
203
|
+
() => cache.subscribe(
|
|
204
|
+
notifyManager2.batchCalls(() => {
|
|
205
|
+
const newIsFetching = queryClient.isFetching(filters);
|
|
206
|
+
if (isFetching !== newIsFetching) {
|
|
207
|
+
isFetching = newIsFetching;
|
|
208
|
+
ngZone.run(() => {
|
|
209
|
+
result.set(isFetching);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
)
|
|
214
|
+
);
|
|
215
|
+
destroyRef.onDestroy(unsubscribe);
|
|
216
|
+
return result;
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
// src/inject-is-mutating.ts
|
|
220
|
-
import {
|
|
220
|
+
import {
|
|
221
|
+
DestroyRef as DestroyRef2,
|
|
222
|
+
Injector as Injector4,
|
|
223
|
+
NgZone as NgZone3,
|
|
224
|
+
assertInInjectionContext as assertInInjectionContext4,
|
|
225
|
+
inject as inject5,
|
|
226
|
+
signal as signal3
|
|
227
|
+
} from "@angular/core";
|
|
221
228
|
import { QueryClient as QueryClient3, notifyManager as notifyManager3 } from "@tanstack/query-core";
|
|
222
229
|
function injectIsMutating(filters, options) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
)
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
230
|
+
!options?.injector && assertInInjectionContext4(injectIsMutating);
|
|
231
|
+
const injector = options?.injector ?? inject5(Injector4);
|
|
232
|
+
const destroyRef = injector.get(DestroyRef2);
|
|
233
|
+
const ngZone = injector.get(NgZone3);
|
|
234
|
+
const queryClient = injector.get(QueryClient3);
|
|
235
|
+
const cache = queryClient.getMutationCache();
|
|
236
|
+
let isMutating = queryClient.isMutating(filters);
|
|
237
|
+
const result = signal3(isMutating);
|
|
238
|
+
const unsubscribe = ngZone.runOutsideAngular(
|
|
239
|
+
() => cache.subscribe(
|
|
240
|
+
notifyManager3.batchCalls(() => {
|
|
241
|
+
const newIsMutating = queryClient.isMutating(filters);
|
|
242
|
+
if (isMutating !== newIsMutating) {
|
|
243
|
+
isMutating = newIsMutating;
|
|
244
|
+
ngZone.run(() => {
|
|
245
|
+
result.set(isMutating);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
)
|
|
250
|
+
);
|
|
251
|
+
destroyRef.onDestroy(unsubscribe);
|
|
252
|
+
return result;
|
|
246
253
|
}
|
|
247
254
|
|
|
248
255
|
// src/inject-mutation.ts
|
|
249
256
|
import {
|
|
250
257
|
DestroyRef as DestroyRef3,
|
|
258
|
+
Injector as Injector5,
|
|
251
259
|
NgZone as NgZone4,
|
|
260
|
+
assertInInjectionContext as assertInInjectionContext5,
|
|
252
261
|
computed as computed4,
|
|
253
262
|
effect as effect2,
|
|
254
263
|
inject as inject6,
|
|
@@ -261,82 +270,88 @@ import {
|
|
|
261
270
|
notifyManager as notifyManager4
|
|
262
271
|
} from "@tanstack/query-core";
|
|
263
272
|
function injectMutation(injectMutationFn, options) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
})();
|
|
275
|
-
const mutateFnSignal = computed4(() => {
|
|
276
|
-
const observer = observerSignal();
|
|
277
|
-
return (variables, mutateOptions) => {
|
|
278
|
-
observer.mutate(variables, mutateOptions).catch(noop);
|
|
279
|
-
};
|
|
273
|
+
!options?.injector && assertInInjectionContext5(injectMutation);
|
|
274
|
+
const injector = options?.injector ?? inject6(Injector5);
|
|
275
|
+
const destroyRef = injector.get(DestroyRef3);
|
|
276
|
+
const ngZone = injector.get(NgZone4);
|
|
277
|
+
const queryClient = injector.get(QueryClient4);
|
|
278
|
+
const optionsSignal = computed4(injectMutationFn);
|
|
279
|
+
const observerSignal = (() => {
|
|
280
|
+
let instance = null;
|
|
281
|
+
return computed4(() => {
|
|
282
|
+
return instance ||= new MutationObserver(queryClient, optionsSignal());
|
|
280
283
|
});
|
|
281
|
-
|
|
284
|
+
})();
|
|
285
|
+
const mutateFnSignal = computed4(() => {
|
|
286
|
+
const observer = observerSignal();
|
|
287
|
+
return (variables, mutateOptions) => {
|
|
288
|
+
observer.mutate(variables, mutateOptions).catch(noop);
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
const resultFromInitialOptionsSignal = computed4(() => {
|
|
292
|
+
const observer = observerSignal();
|
|
293
|
+
return observer.getCurrentResult();
|
|
294
|
+
});
|
|
295
|
+
const resultFromSubscriberSignal = signal4(null);
|
|
296
|
+
effect2(
|
|
297
|
+
() => {
|
|
282
298
|
const observer = observerSignal();
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
const resultFromSubscriber = resultFromSubscriberSignal();
|
|
326
|
-
const resultFromInitialOptions = resultFromInitialOptionsSignal();
|
|
327
|
-
const result = resultFromSubscriber ?? resultFromInitialOptions;
|
|
328
|
-
return {
|
|
329
|
-
...result,
|
|
330
|
-
mutate: mutateFnSignal(),
|
|
331
|
-
mutateAsync: result.mutate
|
|
332
|
-
};
|
|
333
|
-
});
|
|
334
|
-
return signalProxy(resultSignal);
|
|
299
|
+
const observerOptions = optionsSignal();
|
|
300
|
+
untracked3(() => {
|
|
301
|
+
observer.setOptions(observerOptions);
|
|
302
|
+
});
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
injector
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
effect2(
|
|
309
|
+
() => {
|
|
310
|
+
const observer = observerSignal();
|
|
311
|
+
untracked3(() => {
|
|
312
|
+
const unsubscribe = ngZone.runOutsideAngular(
|
|
313
|
+
() => observer.subscribe(
|
|
314
|
+
notifyManager4.batchCalls((state) => {
|
|
315
|
+
ngZone.run(() => {
|
|
316
|
+
if (state.isError && shouldThrowError(observer.options.throwOnError, [state.error])) {
|
|
317
|
+
ngZone.onError.emit(state.error);
|
|
318
|
+
throw state.error;
|
|
319
|
+
}
|
|
320
|
+
resultFromSubscriberSignal.set(state);
|
|
321
|
+
});
|
|
322
|
+
})
|
|
323
|
+
)
|
|
324
|
+
);
|
|
325
|
+
destroyRef.onDestroy(unsubscribe);
|
|
326
|
+
});
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
injector
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
const resultSignal = computed4(() => {
|
|
333
|
+
const resultFromSubscriber = resultFromSubscriberSignal();
|
|
334
|
+
const resultFromInitialOptions = resultFromInitialOptionsSignal();
|
|
335
|
+
const result = resultFromSubscriber ?? resultFromInitialOptions;
|
|
336
|
+
return {
|
|
337
|
+
...result,
|
|
338
|
+
mutate: mutateFnSignal(),
|
|
339
|
+
mutateAsync: result.mutate
|
|
340
|
+
};
|
|
335
341
|
});
|
|
342
|
+
return signalProxy(resultSignal);
|
|
336
343
|
}
|
|
337
344
|
|
|
338
345
|
// src/inject-mutation-state.ts
|
|
339
|
-
import {
|
|
346
|
+
import {
|
|
347
|
+
DestroyRef as DestroyRef4,
|
|
348
|
+
Injector as Injector6,
|
|
349
|
+
NgZone as NgZone5,
|
|
350
|
+
assertInInjectionContext as assertInInjectionContext6,
|
|
351
|
+
computed as computed5,
|
|
352
|
+
inject as inject7,
|
|
353
|
+
signal as signal5
|
|
354
|
+
} from "@angular/core";
|
|
340
355
|
import {
|
|
341
356
|
QueryClient as QueryClient5,
|
|
342
357
|
notifyManager as notifyManager5,
|
|
@@ -348,44 +363,44 @@ function getResult(mutationCache, options) {
|
|
|
348
363
|
);
|
|
349
364
|
}
|
|
350
365
|
function injectMutationState(injectMutationStateFn = () => ({}), options) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
const resultFromSubscriberSignal = signal5(
|
|
363
|
-
null
|
|
364
|
-
);
|
|
365
|
-
const effectiveResultSignal = computed5(() => {
|
|
366
|
-
const optionsResult = resultFromOptionsSignal();
|
|
367
|
-
const subscriberResult = resultFromSubscriberSignal();
|
|
368
|
-
return subscriberResult && subscriberResult[1] > optionsResult[1] ? subscriberResult[0] : optionsResult[0];
|
|
369
|
-
});
|
|
370
|
-
const unsubscribe = ngZone.runOutsideAngular(
|
|
371
|
-
() => mutationCache.subscribe(
|
|
372
|
-
notifyManager5.batchCalls(() => {
|
|
373
|
-
const [lastResult] = effectiveResultSignal();
|
|
374
|
-
const nextResult = replaceEqualDeep(
|
|
375
|
-
lastResult,
|
|
376
|
-
getResult(mutationCache, injectMutationStateFn())
|
|
377
|
-
);
|
|
378
|
-
if (lastResult !== nextResult) {
|
|
379
|
-
ngZone.run(() => {
|
|
380
|
-
resultFromSubscriberSignal.set([nextResult, performance.now()]);
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
})
|
|
384
|
-
)
|
|
385
|
-
);
|
|
386
|
-
destroyRef.onDestroy(unsubscribe);
|
|
387
|
-
return effectiveResultSignal;
|
|
366
|
+
!options?.injector && assertInInjectionContext6(injectMutationState);
|
|
367
|
+
const injector = options?.injector ?? inject7(Injector6);
|
|
368
|
+
const destroyRef = injector.get(DestroyRef4);
|
|
369
|
+
const ngZone = injector.get(NgZone5);
|
|
370
|
+
const queryClient = injector.get(QueryClient5);
|
|
371
|
+
const mutationCache = queryClient.getMutationCache();
|
|
372
|
+
const resultFromOptionsSignal = computed5(() => {
|
|
373
|
+
return [
|
|
374
|
+
getResult(mutationCache, injectMutationStateFn()),
|
|
375
|
+
performance.now()
|
|
376
|
+
];
|
|
388
377
|
});
|
|
378
|
+
const resultFromSubscriberSignal = signal5(
|
|
379
|
+
null
|
|
380
|
+
);
|
|
381
|
+
const effectiveResultSignal = computed5(() => {
|
|
382
|
+
const optionsResult = resultFromOptionsSignal();
|
|
383
|
+
const subscriberResult = resultFromSubscriberSignal();
|
|
384
|
+
return subscriberResult && subscriberResult[1] > optionsResult[1] ? subscriberResult[0] : optionsResult[0];
|
|
385
|
+
});
|
|
386
|
+
const unsubscribe = ngZone.runOutsideAngular(
|
|
387
|
+
() => mutationCache.subscribe(
|
|
388
|
+
notifyManager5.batchCalls(() => {
|
|
389
|
+
const [lastResult] = effectiveResultSignal();
|
|
390
|
+
const nextResult = replaceEqualDeep(
|
|
391
|
+
lastResult,
|
|
392
|
+
getResult(mutationCache, injectMutationStateFn())
|
|
393
|
+
);
|
|
394
|
+
if (lastResult !== nextResult) {
|
|
395
|
+
ngZone.run(() => {
|
|
396
|
+
resultFromSubscriberSignal.set([nextResult, performance.now()]);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
})
|
|
400
|
+
)
|
|
401
|
+
);
|
|
402
|
+
destroyRef.onDestroy(unsubscribe);
|
|
403
|
+
return effectiveResultSignal;
|
|
389
404
|
}
|
|
390
405
|
|
|
391
406
|
// src/inject-queries.ts
|
|
@@ -396,17 +411,21 @@ import {
|
|
|
396
411
|
} from "@tanstack/query-core";
|
|
397
412
|
import {
|
|
398
413
|
DestroyRef as DestroyRef5,
|
|
414
|
+
Injector as Injector7,
|
|
399
415
|
NgZone as NgZone6,
|
|
416
|
+
assertInInjectionContext as assertInInjectionContext7,
|
|
400
417
|
computed as computed6,
|
|
401
418
|
effect as effect3,
|
|
402
419
|
inject as inject8,
|
|
420
|
+
runInInjectionContext as runInInjectionContext2,
|
|
403
421
|
signal as signal6
|
|
404
422
|
} from "@angular/core";
|
|
405
423
|
function injectQueries({
|
|
406
424
|
queries,
|
|
407
425
|
...options
|
|
408
426
|
}, injector) {
|
|
409
|
-
|
|
427
|
+
!injector && assertInInjectionContext7(injectQueries);
|
|
428
|
+
return runInInjectionContext2(injector ?? inject8(Injector7), () => {
|
|
410
429
|
const destroyRef = inject8(DestroyRef5);
|
|
411
430
|
const ngZone = inject8(NgZone6);
|
|
412
431
|
const queryClient = inject8(QueryClient6);
|
|
@@ -446,19 +465,25 @@ function injectQueries({
|
|
|
446
465
|
|
|
447
466
|
// src/inject-query.ts
|
|
448
467
|
import { QueryObserver } from "@tanstack/query-core";
|
|
468
|
+
import {
|
|
469
|
+
Injector as Injector8,
|
|
470
|
+
assertInInjectionContext as assertInInjectionContext8,
|
|
471
|
+
inject as inject9,
|
|
472
|
+
runInInjectionContext as runInInjectionContext3
|
|
473
|
+
} from "@angular/core";
|
|
449
474
|
function injectQuery(injectQueryFn, options) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
options?.injector,
|
|
475
|
+
!options?.injector && assertInInjectionContext8(injectQuery);
|
|
476
|
+
return runInInjectionContext3(
|
|
477
|
+
options?.injector ?? inject9(Injector8),
|
|
453
478
|
() => createBaseQuery(injectQueryFn, QueryObserver)
|
|
454
479
|
);
|
|
455
480
|
}
|
|
456
481
|
|
|
457
482
|
// src/inject-query-client.ts
|
|
458
|
-
import { Injector as
|
|
483
|
+
import { Injector as Injector9, inject as inject10 } from "@angular/core";
|
|
459
484
|
import { QueryClient as QueryClient7 } from "@tanstack/query-core";
|
|
460
485
|
function injectQueryClient(injectOptions = {}) {
|
|
461
|
-
return (injectOptions.injector ??
|
|
486
|
+
return (injectOptions.injector ?? inject10(Injector9)).get(QueryClient7);
|
|
462
487
|
}
|
|
463
488
|
|
|
464
489
|
// src/providers.ts
|
|
@@ -468,7 +493,7 @@ import {
|
|
|
468
493
|
PLATFORM_ID,
|
|
469
494
|
computed as computed7,
|
|
470
495
|
effect as effect4,
|
|
471
|
-
inject as
|
|
496
|
+
inject as inject11,
|
|
472
497
|
makeEnvironmentProviders
|
|
473
498
|
} from "@angular/core";
|
|
474
499
|
import { QueryClient as QueryClient8, onlineManager } from "@tanstack/query-core";
|
|
@@ -490,7 +515,7 @@ function provideTanStackQuery(queryClient, ...features) {
|
|
|
490
515
|
multi: true,
|
|
491
516
|
useValue: () => {
|
|
492
517
|
queryClient.mount();
|
|
493
|
-
|
|
518
|
+
inject11(DestroyRef6).onDestroy(() => queryClient.unmount());
|
|
494
519
|
}
|
|
495
520
|
},
|
|
496
521
|
features.map((feature) => feature.\u0275providers)
|
|
@@ -513,11 +538,11 @@ function withDevtools(withDevtoolsFn) {
|
|
|
513
538
|
provide: ENVIRONMENT_INITIALIZER,
|
|
514
539
|
multi: true,
|
|
515
540
|
useFactory: () => {
|
|
516
|
-
if (!isPlatformBrowser(
|
|
517
|
-
const injectedClient =
|
|
541
|
+
if (!isPlatformBrowser(inject11(PLATFORM_ID))) return noop;
|
|
542
|
+
const injectedClient = inject11(QueryClient8, {
|
|
518
543
|
optional: true
|
|
519
544
|
});
|
|
520
|
-
const destroyRef =
|
|
545
|
+
const destroyRef = inject11(DestroyRef6);
|
|
521
546
|
const options = computed7(() => withDevtoolsFn?.() ?? {});
|
|
522
547
|
let devtools = null;
|
|
523
548
|
let el = null;
|