MCPcopy
hub / github.com/wavetermdev/waveterm / waveEventSubscribeSingle

Function waveEventSubscribeSingle

frontend/app/store/wps.ts:67–86  ·  view source on GitHub ↗
(subscription: WaveEventSubscription<T>)

Source from the content-addressed store, hash-verified

65}
66
67function waveEventSubscribeSingle<T extends WaveEventName>(subscription: WaveEventSubscription<T>): () => void {
68 // console.log("waveEventSubscribeSingle", subscription);
69 if (subscription.handler == null) {
70 return () => {};
71 }
72 const id: string = crypto.randomUUID();
73 let subjects = waveEventSubjects.get(subscription.eventType);
74 if (subjects == null) {
75 subjects = [];
76 waveEventSubjects.set(subscription.eventType, subjects);
77 }
78 const subcont: WaveEventSubjectContainer = {
79 id,
80 handler: subscription.handler as (event: WaveEvent) => void,
81 scope: subscription.scope,
82 };
83 subjects.push(subcont);
84 updateWaveEventSub(subscription.eventType);
85 return () => waveEventUnsubscribe({ id, eventType: subscription.eventType });
86}
87
88function waveEventUnsubscribe(...unsubscribes: WaveEventUnsubscribe[]) {
89 const eventTypeSet = new Set<string>();

Callers 15

setupBadgesSubscriptionFunction · 0.90
initGlobalWaveEventSubsFunction · 0.90
subscribeToConnEventsFunction · 0.90
wpsSubscribeToObjectFunction · 0.90
SysinfoViewFunction · 0.90
TermVDomToolbarNodeFunction · 0.90
TermVDomNodeSingleIdFunction · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90

Calls 5

updateWaveEventSubFunction · 0.85
waveEventUnsubscribeFunction · 0.85
getMethod · 0.80
setMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected