feat(companion): expose runtime event subscription count

This commit is contained in:
William Valentin
2026-02-16 19:32:25 -08:00
parent 9e7d3b0e13
commit d3e571b728
4 changed files with 21 additions and 1 deletions
+3
View File
@@ -110,7 +110,9 @@ describe('CompanionRuntimeClient', () => {
url: 'ws://127.0.0.1:1',
});
const handler = vi.fn();
expect(client.eventSubscriptionCount).toBe(0);
const unsubscribe = client.subscribeEvents(handler);
expect(client.eventSubscriptionCount).toBe(1);
(client as unknown as { handleMessage: (raw: string) => void }).handleMessage(
JSON.stringify({
@@ -133,6 +135,7 @@ describe('CompanionRuntimeClient', () => {
);
expect(handler).toHaveBeenCalledTimes(1);
expect(client.eventSubscriptionCount).toBe(0);
});
it('isolates subscriber callback failures', () => {
+4
View File
@@ -298,6 +298,10 @@ export class CompanionRuntimeClient {
return this.ws?.readyState === WebSocket.OPEN;
}
get eventSubscriptionCount(): number {
return this.eventHandlers.size;
}
async connect(): Promise<void> {
if (this.connected) {
return;