MCPcopy Create free account
hub / github.com/TanStack/query / provideQueryClient

Function provideQueryClient

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

Source from the content-addressed store, hash-verified

20 * ```
21 */
22export function provideQueryClient(
23 queryClient: QueryClient | InjectionToken<QueryClient>,
24): Provider {
25 return {
26 provide: QueryClient,
27 useFactory: () => {
28 const client =
29 queryClient instanceof InjectionToken
30 ? inject(queryClient)
31 : queryClient
32 // Unmount the query client on injector destroy
33 inject(DestroyRef).onDestroy(() => client.unmount())
34 client.mount()
35 return client
36 },
37 }
38}
39
40/**
41 * Sets up providers necessary to enable TanStack Query functionality for Angular applications. Allows

Callers 2

provideTanStackQueryFunction · 0.85

Calls 2

unmountMethod · 0.45
mountMethod · 0.45

Tested by

no test coverage detected