(id: string, callback: (message: ProgressMessage) => void, sendExisting: boolean = true)
| 92 | } |
| 93 | |
| 94 | subscribe(id: string, callback: (message: ProgressMessage) => void, sendExisting: boolean = true): () => void { |
| 95 | const execution = this.executions.get(id); |
| 96 | if (!execution) { |
| 97 | console.warn(`No execution found for id: ${id}`); |
| 98 | return () => {}; |
| 99 | } |
| 100 | |
| 101 | execution.subscribers.add(callback); |
| 102 | |
| 103 | // Send all existing messages to the new subscriber only if requested |
| 104 | if (sendExisting) { |
| 105 | execution.messages.forEach((msg) => callback(msg)); |
| 106 | } |
| 107 | |
| 108 | // Return unsubscribe function |
| 109 | return () => { |
| 110 | execution.subscribers.delete(callback); |
| 111 | }; |
| 112 | } |
| 113 | |
| 114 | getMessages(id: string): ProgressMessage[] { |
| 115 | const execution = this.executions.get(id); |
nothing calls this directly
no outgoing calls
no test coverage detected