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

Function setupQueryCacheSubscription

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

Source from the content-addressed store, hash-verified

2578>()
2579
2580const setupQueryCacheSubscription = () => {
2581 const queryCache = createMemo(() => {
2582 const client = useQueryDevtoolsContext().client
2583 return client.getQueryCache()
2584 })
2585
2586 const unsubscribe = queryCache().subscribe((q) => {
2587 batch(() => {
2588 for (const [callback, value] of queryCacheMap.entries()) {
2589 if (!value.shouldUpdate(q)) continue
2590 value.setter(callback(queryCache))
2591 }
2592 })
2593 })
2594
2595 onCleanup(() => {
2596 queryCacheMap.clear()
2597 unsubscribe()
2598 })
2599
2600 return unsubscribe
2601}
2602
2603const createSubscribeToQueryCacheBatcher = <T,>(
2604 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