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

Function setupMutationCacheSubscription

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

Source from the content-addressed store, hash-verified

2637>()
2638
2639const setupMutationCacheSubscription = () => {
2640 const mutationCache = createMemo(() => {
2641 const client = useQueryDevtoolsContext().client
2642 return client.getMutationCache()
2643 })
2644
2645 const unsubscribe = mutationCache().subscribe(() => {
2646 for (const [callback, setter] of mutationCacheMap.entries()) {
2647 queueMicrotask(() => {
2648 setter(callback(mutationCache))
2649 })
2650 }
2651 })
2652
2653 onCleanup(() => {
2654 mutationCacheMap.clear()
2655 unsubscribe()
2656 })
2657
2658 return unsubscribe
2659}
2660
2661const createSubscribeToMutationCacheBatcher = <T,>(
2662 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