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

Function setupQueryCacheSubscription

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

Source from the content-addressed store, hash-verified

2474>()
2475
2476const setupQueryCacheSubscription = () => {
2477 const queryCache = createMemo(() => {
2478 const client = useQueryDevtoolsContext().client
2479 return client.getQueryCache()
2480 })
2481
2482 const unsubscribe = queryCache().subscribe((q) => {
2483 batch(() => {
2484 for (const [callback, value] of queryCacheMap.entries()) {
2485 if (!value.shouldUpdate(q)) continue
2486 value.setter(callback(queryCache))
2487 }
2488 })
2489 })
2490
2491 onCleanup(() => {
2492 queryCacheMap.clear()
2493 unsubscribe()
2494 })
2495
2496 return unsubscribe
2497}
2498
2499const createSubscribeToQueryCacheBatcher = <T,>(
2500 callback: (queryCache: Accessor<QueryCache>) => Exclude<T, Function>,

Callers 1

ContentViewFunction · 0.85

Calls 5

useQueryDevtoolsContextFunction · 0.90
getQueryCacheMethod · 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…