feat(companion): return clearEventSubscriptions result counts

This commit is contained in:
William Valentin
2026-02-16 22:26:23 -08:00
parent 06bdb27f70
commit ffc7c4e9b3
7 changed files with 49 additions and 13 deletions
+12 -2
View File
@@ -68,6 +68,11 @@ export interface ConnectionSnapshot {
idle: boolean;
}
export interface ClearEventSubscriptionsResult {
clearedSubscriptions: number;
cancelledWaits: number;
}
export type CompanionEventHandler = (event: string, data: unknown) => void;
export type CompanionTypedEventHandler<TData = unknown> = (data: TData) => void;
export type CompanionEventPredicate<TData = unknown> = (data: TData) => boolean;
@@ -464,9 +469,14 @@ export class CompanionRuntimeClient {
};
}
clearEventSubscriptions(): void {
clearEventSubscriptions(): ClearEventSubscriptionsResult {
const clearedSubscriptions = this.eventHandlers.size;
this.eventHandlers.clear();
this.rejectEventWaits(new Error('Event subscriptions cleared'));
const cancelledWaits = this.rejectEventWaits(new Error('Event subscriptions cleared'));
return {
clearedSubscriptions,
cancelledWaits,
};
}
cancelPendingEventWaits(reason = 'Event waits cancelled'): number {