feat(companion): expose runtime event subscription count
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user