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

useIsMutating.md

56 lines1.5 KB

1---
2id: useIsMutating
3title: useIsMutating
4redirect_from:
5 - framework/vue/reference/useIsMutating
6---
7​
8<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
9​
10```ts
11function useIsMutating(filters?: UseIsMutatingFilters, queryClient?: QueryClient): Ref<number>;
12```
13​
14Defined in: [packages/vue-query/src/useMutationState.ts:55](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L55)
15​
16The `useIsMutating` composable returns a `ref` to the `number` of mutations that your application currently
17has `pending` (useful for app-wide loading indicators).
18​
19`filters` may be a plain object, `MaybeRefDeep`, or a reactive getter (`() => ({ ... })`) β€” pass a getter if
20the filters themselves depend on other reactive state.
21​
22## Parameters
23​
24### filters?
25​
26[`UseIsMutatingFilters`](../type-aliases/UseIsMutatingFilters.md) = `{}`
27​
28The [MutationFilters](../interfaces/MutationFilters.md) to narrow down the matched mutations.
29​
30### queryClient?
31​
32[`QueryClient`](../classes/QueryClient.md)
33​
34Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
35will be used.
36​
37## Returns
38​
39`Ref`\<`number`\>
40​
41A `ref` to the `number` of the mutations that your application currently has `pending`.
42​
43## Example
44​
45```vue
46<script setup lang="ts">
47import { useIsMutating } from '@tanstack/vue-query'
48​
49// How many mutations matching the posts prefix are in progress?
50const isMutatingPosts = useIsMutating({ mutationKey: ['posts'] })
51</script>
52​
53<template>
54 <span v-if="isMutatingPosts">Saving posts...</span>
55</template>
56```