MCPcopy Create free account
hub / github.com/GCWing/BitFun / subscribe

Method subscribe

src/web-ui/src/tools/git/state/GitStateManager.ts:98–122  ·  view source on GitHub ↗

* Subscribe to repository state changes. * @returns Unsubscribe function.

(
    repositoryPath: string,
    callback: GitStateSubscriber,
    options: SubscribeOptions = {}
  )

Source from the content-addressed store, hash-verified

96 * @returns Unsubscribe function.
97 */
98 subscribe(
99 repositoryPath: string,
100 callback: GitStateSubscriber,
101 options: SubscribeOptions = {}
102 ): () => void {
103 const normalizedPath = this.normalizePath(repositoryPath);
104
105 if (!this.subscribers.has(normalizedPath)) {
106 this.subscribers.set(normalizedPath, new Set());
107 }
108
109 const entry: SubscriberEntry = { callback, options };
110 this.subscribers.get(normalizedPath)!.add(entry);
111
112 if (options.immediate !== false) {
113 const currentState = this.states.get(normalizedPath);
114 if (currentState) {
115 callback(currentState, null, ['basic', 'status', 'detailed']);
116 }
117 }
118
119 return () => {
120 this.subscribers.get(normalizedPath)?.delete(entry);
121 };
122 }
123
124 /**
125 * Get current state synchronously (cached).

Callers 3

useGitStateFunction · 0.45
useSnapshotStateFunction · 0.45
PlanViewerFunction · 0.45

Calls 6

normalizePathMethod · 0.95
hasMethod · 0.45
setMethod · 0.45
addMethod · 0.45
getMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected