MCPcopy
hub / github.com/TanStack/query / setupMutationCacheSubscription

Function setupMutationCacheSubscription

packages/query-devtools/src/Devtools.tsx:2535–2555  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2533>()
2534
2535const setupMutationCacheSubscription = () => {
2536 const mutationCache = createMemo(() => {
2537 const client = useQueryDevtoolsContext().client
2538 return client.getMutationCache()
2539 })
2540
2541 const unsubscribe = mutationCache().subscribe(() => {
2542 for (const [callback, setter] of mutationCacheMap.entries()) {
2543 queueMicrotask(() => {
2544 setter(callback(mutationCache))
2545 })
2546 }
2547 })
2548
2549 onCleanup(() => {
2550 mutationCacheMap.clear()
2551 unsubscribe()
2552 })
2553
2554 return unsubscribe
2555}
2556
2557const createSubscribeToMutationCacheBatcher = <T,>(
2558 callback: (queryCache: Accessor<MutationCache>) => Exclude<T, Function>,

Callers 1

ContentViewFunction · 0.85

Calls 5

useQueryDevtoolsContextFunction · 0.90
getMutationCacheMethod · 0.80
unsubscribeFunction · 0.70
subscribeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…