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<readonly unknown[]>, "fetchStatus">, options?: InjectIsFetchingOptions): Signal<number>;
10```
11β
12Defined in: [packages/angular-query-experimental/src/inject-is-fetching.ts:63](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-fetching.ts#L63)
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)\<readonly `unknown`[]\>, `"fetchStatus"`\>
22β
23The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries.
24β
25<a id="filters-properties"></a>
26β
27#### `filters` properties
28β
29Built from [`QueryFilters`](../interfaces/QueryFilters.md#properties). See the type above for what it changes.
30β
31### options?
32β
33[`InjectIsFetchingOptions`](../interfaces/InjectIsFetchingOptions.md)
34β
35Additional configuration
36β
37<a id="options-properties"></a>
38β
39#### `options` properties
40β
41| Property | Type | Description |
42| ------ | ------ | ------ |
43| <a id="options-property-injector"></a> `injector?` | `Injector` | The `Injector` in which to create the isFetching signal. If this is not provided, the current injection context will be used instead (via `inject`). |
44β
45## Returns
46β
47`Signal`\<`number`\>
48β
49A `Signal` with the number of queries that your application is currently loading or fetching in
50the background.
51β
52## Examples
53β
54```angular-ts
55@Component({
56 selector: 'posts-fetching-indicator',
57 template: `
58 @if (isFetchingPosts()) {
59 <span>Refreshing posts...</span>
60 }
61 `,
62})
63export class PostsFetchingIndicator {
64 // How many queries matching the posts prefix are fetching?
65 readonly isFetchingPosts = injectIsFetching({ queryKey: ['posts'] })
66}
67```
68β
69A global loading indicator for any query fetching in the background, not just the ones on screen:
70```angular-ts
71@Component({
72 selector: 'global-loading-indicator',
73 template: `
74 @if (isFetching()) {
75 <div>Queries are fetching in the background...</div>
76 }
77 `,
78})
79export class GlobalLoadingIndicator {
80 readonly isFetching = injectIsFetching()
81}
82```