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

useIsMutating.md

54 lines1.5 KB

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