MCPcopy Create free account
hub / github.com/astercloud/aster / subscribe

Method subscribe

ui/src/protocol/message-processor.ts:969–981  ·  view source on GitHub ↗

* Subscribe to surface changes

(surfaceId: string, listener: (surface: Surface) => void)

Source from the content-addressed store, hash-verified

967 * Subscribe to surface changes
968 */
969 subscribe(surfaceId: string, listener: (surface: Surface) => void): () => void {
970 let listeners = this.listeners.get(surfaceId);
971 if (!listeners) {
972 listeners = new Set();
973 this.listeners.set(surfaceId, listeners);
974 }
975 listeners.add(listener);
976
977 // Return unsubscribe function
978 return () => {
979 listeners?.delete(listener);
980 };
981 }
982
983 /**
984 * Notify listeners of surface changes

Callers 3

subscribeFunction · 0.45

Calls 3

getMethod · 0.45
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected