Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

app.config.ts

31 lines883 Bytes

1import type { ApplicationConfig } from '@angular/core'
2import { provideClientHydration, withEventReplay } from '@angular/platform-browser'
3import {
4 QueryClient,
5 provideTanStackQuery,
6} from '@tanstack/angular-query-experimental'
7import { withDevtools } from '@tanstack/angular-query-devtools'
8​
9export const sharedQueryDefaults = {
10 staleTime: 1000 * 30,
11 gcTime: 1000 * 60 * 60 * 24,
12} as const
13​
14export const createBrowserQueryClient = () =>
15 new QueryClient({
16 defaultOptions: {
17 queries: { ...sharedQueryDefaults },
18 },
19 })
20​
21export const getBaseAppConfig = (queryClient: QueryClient): ApplicationConfig => {
22 return {
23 providers: [
24 provideClientHydration(withEventReplay()),
25 provideTanStackQuery(queryClient, withDevtools()),
26 ],
27 }
29​
30export const getClientAppConfig = (): ApplicationConfig =>
31 getBaseAppConfig(createBrowserQueryClient())