function provideTanStackQuery(queryClient, ...features): Provider[]
function provideTanStackQuery(queryClient, ...features): Provider[]
Richtet die notwendigen Provider ein, um die TanStack Query-Funktionalität für Angular-Anwendungen zu aktivieren.
Ermöglicht die Konfiguration eines QueryClient und optionaler Features wie Entwicklertools.
Beispiel - Standalone
import {
provideTanStackQuery,
QueryClient,
} from '@tanstack/angular-query-experimental'
bootstrapApplication(AppComponent, {
providers: [provideTanStackQuery(new QueryClient())],
})
import {
provideTanStackQuery,
QueryClient,
} from '@tanstack/angular-query-experimental'
bootstrapApplication(AppComponent, {
providers: [provideTanStackQuery(new QueryClient())],
})
Beispiel - NgModule-basiert
import {
provideTanStackQuery,
QueryClient,
} from '@tanstack/angular-query-experimental'
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule],
providers: [provideTanStackQuery(new QueryClient())],
bootstrap: [AppComponent],
})
export class AppModule {}
import {
provideTanStackQuery,
QueryClient,
} from '@tanstack/angular-query-experimental'
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule],
providers: [provideTanStackQuery(new QueryClient())],
bootstrap: [AppComponent],
})
export class AppModule {}
Sie können auch optionale Entwicklertools aktivieren, indem Sie withDevtools hinzufügen. Standardmäßig werden die Tools dann im Entwicklungsmodus Ihrer App geladen.
import {
provideTanStackQuery,
withDevtools
QueryClient,
} from '@tanstack/angular-query-experimental'
bootstrapApplication(AppComponent,
{
providers: [
provideTanStackQuery(new QueryClient(), withDevtools())
]
}
)
import {
provideTanStackQuery,
withDevtools
QueryClient,
} from '@tanstack/angular-query-experimental'
bootstrapApplication(AppComponent,
{
providers: [
provideTanStackQuery(new QueryClient(), withDevtools())
]
}
)
Beispiel: Verwendung eines InjectionToken
export const MY_QUERY_CLIENT = new InjectionToken('', {
factory: () => new QueryClient(),
})
// In a lazy loaded route or lazy loaded component's providers array:
providers: [provideTanStackQuery(MY_QUERY_CLIENT)]
export const MY_QUERY_CLIENT = new InjectionToken('', {
factory: () => new QueryClient(),
})
// In a lazy loaded route or lazy loaded component's providers array:
providers: [provideTanStackQuery(MY_QUERY_CLIENT)]
Eine QueryClient-Instanz oder ein InjectionToken, das einen QueryClient bereitstellt.
QueryClient | InjectionToken<QueryClient>
...QueryFeatures[]
Optionale Features zur Konfiguration zusätzlicher Query-Funktionalität.
Provider[]
Eine Reihe von Providern zur Einrichtung von TanStack Query.