* 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() * ```
()
| 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. |