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

Function setupMutationCacheSubscription

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

Source from the content-addressed store, hash-verified

2756}
2757
2758const setupMutationCacheSubscription = () => {
2759 const { mutationCacheSubscriptions } = useDevtoolsSubscriptions()
2760 const mutationCache = createMemo(() => {
2761 const client = useQueryDevtoolsContext().client
2762 return client.getMutationCache()
2763 })
2764
2765 createEffect(() => {
2766 const cache = mutationCache()
2767 let active = true
2768 const unsubscribe = cache.subscribe((event) => {
2769 mutationCacheSubscriptions.notify(
2770 () => cache,
2771 event,
2772 (update) => {
2773 queueMicrotask(() => {
2774 if (active) update()
2775 })
2776 },
2777 )
2778 })
2779 onCleanup(() => {
2780 active = false
2781 unsubscribe()
2782 })
2783 })
2784}
2785
2786const createSubscribeToMutationCacheBatcher = <T,>(
2787 callback: (

Callers 1

ContentViewFunction · 0.85

Calls 7

useDevtoolsSubscriptionsFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
updateFunction · 0.85
getMutationCacheMethod · 0.80
unsubscribeFunction · 0.70
subscribeMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected