Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

injectIsMutating.md

66 lines1.9 KB

1---
2id: injectIsMutating
3title: injectIsMutating
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8```ts
9function injectIsMutating(filters?: Omit<MutationFilters<unknown, Error, unknown, unknown>, "status">, options?: InjectIsMutatingOptions): Signal<number>;
10```
11​
12Defined in: [packages/angular-query-experimental/src/inject-is-mutating.ts:47](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-mutating.ts#L47)
13​
14Injects a signal that tracks the number of mutations that your application currently has `pending`
15(useful for app-wide loading indicators).
16​
17## Parameters
18​
19### filters?
20​
21`Omit`\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>, `"status"`\>
22​
23The [MutationFilters](../interfaces/MutationFilters.md) to narrow down the matched mutations.
24​
25<a id="filters-properties"></a>
26​
27#### `filters` properties
28​
29Built from [`MutationFilters`](../interfaces/MutationFilters.md#properties). See the type above for what it changes.
30​
31### options?
32​
33[`InjectIsMutatingOptions`](../interfaces/InjectIsMutatingOptions.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 isMutating 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 mutations that your application currently has `pending`.
50​
51## Example
52​
53```angular-ts
54@Component({
55 selector: 'posts-mutating-indicator',
56 template: `
57 @if (isMutatingPosts()) {
58 <span>Saving posts...</span>
59 }
60 `,
61})
62export class PostsMutatingIndicator {
63 // How many mutations matching the posts prefix are in progress?
64 readonly isMutatingPosts = injectIsMutating({ mutationKey: ['posts'] })
66```