Open History to see the last commit
1import { provideHttpClient, withFetch } from '@angular/common/http'
2import { QueryClient, provideTanStackQuery } from '@tanstack/angular-query'
3import { withPersistQueryClient } from '@tanstack/angular-query-persist-client'
4import { withDevtools } from '@tanstack/angular-query-devtools'
5import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
6import type { ApplicationConfig } from '@angular/core'
7β
8const localStoragePersister = createAsyncStoragePersister({
9 storage: window.localStorage,
10})
11β
12export const appConfig: ApplicationConfig = {
13 providers: [
14 provideHttpClient(withFetch()),
15 provideTanStackQuery(
16 () =>
17 new QueryClient({
18 defaultOptions: {
19 queries: {
20 staleTime: 1000 * 60, // 1 minute
21 gcTime: 1000 * 60 * 60 * 24, // 24 hours
22 },
23 },
24 }),
25 withDevtools(),
26 withPersistQueryClient(() => ({
27 persistOptions: {
28 persister: localStoragePersister,
29 },
30 })),
31 ),
32 ],
33}