Open History to see the last commit
1---
2id: injectIsFetching
3title: injectIsFetching
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8```ts
9function injectIsFetching(filters?: () => Omit<QueryFilters, "fetchStatus">): Signal<number>;
10```
11β
12Defined in: [packages/angular-query/src/inject-is-fetching.ts:46](https://github.com/TanStack/query/blob/main/packages/angular-query/src/inject-is-fetching.ts#L46)
13β
14Injects a signal that tracks the number of queries that your application is loading or fetching in the
15background (useful for app-wide loading indicators).
16β
17## Parameters
18β
19### filters?
20β
21() => `Omit`\<[`QueryFilters`](../interfaces/QueryFilters.md), `"fetchStatus"`\>
22β
23A function returning the [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. Similar
24to `computed` from Angular, this function runs in the reactive context, so signals read inside it
25re-narrow the matched queries.
26β
27<a id="filters-properties"></a>
28β
29#### `filters` properties
30β
31Built from [`QueryFilters`](../interfaces/QueryFilters.md#properties). See the type above for what it changes.
32β
33## Returns
34β
35`Signal`\<`number`\>
36β
37A `Signal` with the number of queries that your application is currently loading or fetching in
38the background.
39β
40## Examples
41β
42```angular-ts
43@Component({
44 selector: 'posts-fetching-indicator',
45 template: `
46 @if (isFetchingPosts()) {
47 <span>Refreshing posts...</span>
48 }
49 `,
50})
51export class PostsFetchingIndicator {
52 // How many queries matching the posts prefix are fetching?
53 readonly isFetchingPosts = injectIsFetching(() => ({ queryKey: ['posts'] }))
54}
55```
56β
57A global loading indicator for any query fetching in the background, not just the ones on screen:
58```angular-ts
59@Component({
60 selector: 'global-loading-indicator',
61 template: `
62 @if (isFetching()) {
63 <div>Queries are fetching in the background...</div>
64 }
65 `,
66})
67export class GlobalLoadingIndicator {
68 readonly isFetching = injectIsFetching()
69}
70```