MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / subscribe

Function subscribe

graph-ui/src/graph/edge-motion.ts:19–32  ·  view source on GitHub ↗
(notify: () => void)

Source from the content-addressed store, hash-verified

17const subscribers = new Set<() => void>();
18let detach: (() => void) | undefined;
19function subscribe(notify: () => void): () => void {
20 if (!subscribers.size) {
21 const broadcast = () => subscribers.forEach(listener => listener());
22 const query = typeof window.matchMedia === 'function' ? window.matchMedia('(prefers-reduced-motion: reduce)') : undefined;
23 window.addEventListener(CHANGE, broadcast); window.addEventListener('storage', broadcast);
24 document.addEventListener('visibilitychange', broadcast); query?.addEventListener('change', broadcast);
25 detach = () => {
26 window.removeEventListener(CHANGE, broadcast); window.removeEventListener('storage', broadcast);
27 document.removeEventListener('visibilitychange', broadcast); query?.removeEventListener('change', broadcast);
28 };
29 }
30 subscribers.add(notify);
31 return () => { subscribers.delete(notify); if (!subscribers.size) { detach?.(); detach = undefined; } };
32}
33const motionSnapshot = () => edgeMotionPreference() && !reducedMotion() && !document.hidden;
34export function useEdgeMotion(active = true): boolean {
35 return useSyncExternalStore(subscribe, motionSnapshot, () => false) && active;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected