MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / subscribeToKey

Function subscribeToKey

cli/src/hooks/use-activity-query.ts:62–75  ·  view source on GitHub ↗

* Subscribe to cache changes for a specific key. Used by useSyncExternalStore.

(key: string, callback: () => void)

Source from the content-addressed store, hash-verified

60 * Subscribe to cache changes for a specific key. Used by useSyncExternalStore.
61 */
62function subscribeToKey(key: string, callback: () => void): () => void {
63 let listeners = cache.keyListeners.get(key)
64 if (!listeners) {
65 listeners = new Set()
66 cache.keyListeners.set(key, listeners)
67 }
68 listeners.add(callback)
69 return () => {
70 listeners!.delete(callback)
71 if (listeners!.size === 0) {
72 cache.keyListeners.delete(key)
73 }
74 }
75}
76
77/**
78 * Snapshot includes BOTH entry + isFetching, and is memoized so Object.is only changes

Callers 1

useActivityQueryFunction · 0.85

Calls 3

setMethod · 0.80
deleteMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected