Open History to see the last commit
1---
2id: background-fetching-indicators
3title: Background Fetching Indicators
4ref: docs/framework/react/guides/background-fetching-indicators.md
5replace:
6 {
7 'useIsFetching': 'injectIsFetching',
8 'hook': 'function',
9 '@tanstack/react-query': '@tanstack/angular-query-experimental',
10 }
11---
12β
13[//]: # 'Example'
14β
15```angular-ts
16@Component({
17 selector: 'todos',
18 template: `
19 @if (todosQuery.isPending()) {
20 Loading...
21 } @else if (todosQuery.isError()) {
22 An error has occurred: {{ todosQuery.error().message }}
23 } @else if (todosQuery.isSuccess()) {
24 @if (todosQuery.isFetching()) {
25 Refreshing...
26 }
27 @for (todos of todosQuery.data(); track todo.id) {
28 <todo [todo]="todo" />
29 }
30 }
31 `,
32})
33class TodosComponent {
34 readonly todosQuery = injectQuery(() => ({
35 queryKey: ['todos'],
36 queryFn: fetchTodos,
37 }))
38}
39```
40β
41[//]: # 'Example'
42[//]: # 'Example2'
43β
44```angular-ts
45import { injectIsFetching } from '@tanstack/angular-query-experimental'
46β
47@Component({
48 selector: 'global-loading-indicator',
49 template: `
50 @if (isFetching()) {
51 <div>Queries are fetching in the background...</div>
52 }
53 `,
54})
55export class GlobalLoadingIndicatorComponent {
56 readonly isFetching = injectIsFetching()
57}
58```
59β
60[//]: # 'Example2'