dockge/common/agent-socket.ts

16 lines
401 B
TypeScript
Raw Normal View History

2023-12-25 20:12:44 +00:00
export class AgentSocket {
eventList : Map<string, (...args : unknown[]) => void> = new Map();
on(event : string, callback : (...args : unknown[]) => void) {
this.eventList.set(event, callback);
}
call(eventName : string, ...args : unknown[]) {
const callback = this.eventList.get(eventName);
if (callback) {
callback(...args);
}
}
}