MCPcopy Create free account
hub / github.com/TanStack/query / clear

Method clear

packages/query-core/src/mutationCache.ts:274–284  ·  view source on GitHub ↗

* Removes all mutations and clears their garbage collection timers. * Mutations that are already running continue to execute. * @example * ```ts * const mutationCache = queryClient.getMutationCache() * * mutationCache.clear() * ```

()

Source from the content-addressed store, hash-verified

272 * ```
273 */
274 clear(): void {
275 notifyManager.batch(() => {
276 const mutations = this.getAll()
277 this.#mutations.clear()
278 this.#scopes.clear()
279 mutations.forEach((mutation) => mutation.destroy())
280 mutations.forEach((mutation) => {
281 this.notify({ type: 'removed', mutation })
282 })
283 })
284 }
285
286 /**
287 * Returns all mutations within the cache.

Callers

nothing calls this directly

Calls 3

getAllMethod · 0.95
notifyMethod · 0.95
destroyMethod · 0.45

Tested by

no test coverage detected