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

Function setupMutationCacheSubscription

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

Source from the content-addressed store, hash-verified

2253}
2254
2255const setupMutationCacheSubscription = () => {
2256 const { mutationCacheSubscriptions } = useDevtoolsSubscriptions()
2257 const mutationCache = createMemo(() => {
2258 const client = useQueryDevtoolsContext().client
2259 return client.getMutationCache()
2260 })
2261
2262 createEffect(() => {
2263 const cache = mutationCache()
2264 let active = true
2265 const unsubscribe = cache.subscribe((event) => {
2266 mutationCacheSubscriptions.notify(
2267 () => cache,
2268 event,
2269 (update) => {
2270 queueMicrotask(() => {
2271 if (active) update()
2272 })
2273 },
2274 )
2275 })
2276 onCleanup(() => {
2277 active = false
2278 unsubscribe()
2279 })
2280 })
2281}
2282
2283const createSubscribeToMutationCacheBatcher = <T,>(
2284 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