Defined in: packages/query-core/src/mutationCache.ts:124
The MutationCache is the storage for mutations.
Normally, you will not interact with the MutationCache directly and instead use a QueryClient. You can subscribe to it (inherited from Subscribable) to be informed of safe/known updates to the cache, such as mutations being added, removed, or updated.
const unsubscribe = mutationCache.subscribe((event) => {
console.log(event.type, event.mutation)
})
const unsubscribe = mutationCache.subscribe((event) => {
console.log(event.type, event.mutation)
})
new MutationCache(config: MutationCacheConfig): MutationCache;
new MutationCache(config: MutationCacheConfig): MutationCache;
Defined in: packages/query-core/src/mutationCache.ts:129
MutationCacheConfig = {}
MutationCache
Subscribable<MutationCacheListener>.constructor
Subscribable<MutationCacheListener>.constructor
config: MutationCacheConfig = {};
config: MutationCacheConfig = {};
Defined in: packages/query-core/src/mutationCache.ts:129
protected listeners: Set<MutationCacheListener>;
protected listeners: Set<MutationCacheListener>;
Defined in: packages/query-core/src/subscribable.ts:2
Subscribable.listeners
Subscribable.listeners
clear(): void;
clear(): void;
Defined in: packages/query-core/src/mutationCache.ts:236
Removes all mutations from the cache.
void
const mutationCache = queryClient.getMutationCache()
mutationCache.clear()
const mutationCache = queryClient.getMutationCache()
mutationCache.clear()
find<TData, TError, TVariables, TOnMutateResult>(filters: MutationFilters):
| Mutation<TData, TError, TVariables, TOnMutateResult>
| undefined;
find<TData, TError, TVariables, TOnMutateResult>(filters: MutationFilters):
| Mutation<TData, TError, TVariables, TOnMutateResult>
| undefined;
Defined in: packages/query-core/src/mutationCache.ts:278
A slightly more advanced method that can be used to get an existing mutation instance from the cache. If the mutation does not exist, undefined is returned.
This is not typically needed for most applications, but can come in handy when needing more information about a mutation in rare scenarios.
TData = unknown
TError = Error
TVariables = any
TOnMutateResult = unknown
| Mutation<TData, TError, TVariables, TOnMutateResult> | undefined
const mutationCache = queryClient.getMutationCache()
const mutation = mutationCache.find({ mutationKey: ['addPost'] })
const mutationCache = queryClient.getMutationCache()
const mutation = mutationCache.find({ mutationKey: ['addPost'] })
findAll(filters: MutationFilters): Mutation<unknown, Error, unknown, unknown>[];
findAll(filters: MutationFilters): Mutation<unknown, Error, unknown, unknown>[];
Defined in: packages/query-core/src/mutationCache.ts:308
An even more advanced method that can be used to get existing mutation instances from the cache that match the given filters. If no mutations match, an empty array is returned.
This is not typically needed for most applications, but can come in handy when needing more information about mutations in rare scenarios.
MutationFilters = {}
Mutation<unknown, Error, unknown, unknown>[]
const mutationCache = queryClient.getMutationCache()
const mutations = mutationCache.findAll({ mutationKey: ['addPost'] })
const mutationCache = queryClient.getMutationCache()
const mutations = mutationCache.findAll({ mutationKey: ['addPost'] })
getAll(): Mutation<unknown, Error, unknown, unknown>[];
getAll(): Mutation<unknown, Error, unknown, unknown>[];
Defined in: packages/query-core/src/mutationCache.ts:259
Returns all mutations within the cache.
This is not typically needed for most applications, but can come in handy when needing more information about a mutation in rare scenarios.
Mutation<unknown, Error, unknown, unknown>[]
const mutationCache = queryClient.getMutationCache()
const mutations = mutationCache.getAll()
const mutationCache = queryClient.getMutationCache()
const mutations = mutationCache.getAll()
hasListeners(): boolean;
hasListeners(): boolean;
Defined in: packages/query-core/src/subscribable.ts:19
boolean
Subscribable.hasListeners
Subscribable.hasListeners
protected onSubscribe(): void;
protected onSubscribe(): void;
Defined in: packages/query-core/src/subscribable.ts:23
void
Subscribable.onSubscribe
Subscribable.onSubscribe
protected onUnsubscribe(): void;
protected onUnsubscribe(): void;
Defined in: packages/query-core/src/subscribable.ts:27
void
Subscribable.onUnsubscribe
Subscribable.onUnsubscribe
subscribe(listener: MutationCacheListener): () => void;
subscribe(listener: MutationCacheListener): () => void;
Defined in: packages/query-core/src/subscribable.ts:8
MutationCacheListener
(): void;
(): void;
void
Subscribable.subscribe
Subscribable.subscribe