MCPcopy
hub / github.com/TanStack/query / provideQueryClient

Function provideQueryClient

packages/angular-query-experimental/src/providers.ts:14–30  ·  view source on GitHub ↗
(
  queryClient: QueryClient | InjectionToken<QueryClient>,
)

Source from the content-addressed store, hash-verified

12 * @returns a provider object that can be used to provide the `QueryClient` instance.
13 */
14export function provideQueryClient(
15 queryClient: QueryClient | InjectionToken<QueryClient>,
16): Provider {
17 return {
18 provide: QueryClient,
19 useFactory: () => {
20 const client =
21 queryClient instanceof InjectionToken
22 ? inject(queryClient)
23 : queryClient
24 // Unmount the query client on injector destroy
25 inject(DestroyRef).onDestroy(() => client.unmount())
26 client.mount()
27 return client
28 },
29 }
30}
31
32/**
33 * Sets up providers necessary to enable TanStack Query functionality for Angular applications.

Callers 2

provideTanStackQueryFunction · 0.85

Calls 2

unmountMethod · 0.45
mountMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…