MCPcopy Create free account
hub / github.com/TanStack/db / unloadSubset

Function unloadSubset

packages/query-db-collection/src/query.ts:1701–1718  ·  view source on GitHub ↗
(options: LoadSubsetOptions)

Source from the content-addressed store, hash-verified

1699 * by TanStack Query, allowing quick remounts to restore data without refetching.
1700 */
1701 const unloadSubset = (options: LoadSubsetOptions) => {
1702 // 1. Same predicates → 2. Same queryKey
1703 const key = generateQueryKeyFromOptions(options)
1704 const hashedQueryKey = hashKey(key)
1705
1706 // 3. Decrement refcount
1707 const currentCount = queryRefCounts.get(hashedQueryKey) || 0
1708 const newCount = currentCount - 1
1709
1710 // Update refcount
1711 if (newCount <= 0) {
1712 queryRefCounts.set(hashedQueryKey, 0)
1713 cleanupQueryIfIdle(hashedQueryKey)
1714 } else {
1715 // Still have other references, just decrement
1716 queryRefCounts.set(hashedQueryKey, newCount)
1717 }
1718 }
1719
1720 // Create deduplicated loadSubset wrapper for non-eager modes
1721 // This prevents redundant snapshot requests when multiple concurrent

Callers

nothing calls this directly

Calls 4

cleanupQueryIfIdleFunction · 0.85
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected