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

Method on

src/web-ui/src/tools/git/services/GitEventService.ts:26–53  ·  view source on GitHub ↗
(
    eventType: T, 
    listener: GitEventListener<T>,
    options?: GitEventSubscriptionOptions
  )

Source from the content-addressed store, hash-verified

24 }
25
26 on<T extends GitEventType>(
27 eventType: T,
28 listener: GitEventListener<T>,
29 options?: GitEventSubscriptionOptions
30 ): () => void {
31 const eventName = this.getEventName(eventType);
32
33 const wrappedListener = (data: Extract<GitEvent, { type: T }>['data']) => {
34 if (options?.filter && !options.filter(data)) {
35 return;
36 }
37
38 if (options?.repositoryPath && 'repositoryPath' in data) {
39 if (data.repositoryPath !== options.repositoryPath) {
40 return;
41 }
42 }
43
44 const event = { type: eventType, data } as Extract<GitEvent, { type: T }>;
45 listener(event);
46 };
47
48 if (options?.once) {
49 return globalEventBus.once(eventName, wrappedListener as any);
50 }
51
52 return globalEventBus.on(eventName, wrappedListener as any);
53 }
54
55 once<T extends GitEventType>(
56 eventType: T,

Callers 4

onceMethod · 0.95
onRepositoryEventMethod · 0.95
onStatusChangedMethod · 0.95
onOperationMethod · 0.95

Calls 3

getEventNameMethod · 0.95
onceMethod · 0.65
onMethod · 0.65

Tested by

no test coverage detected