feat(companion): return clearEventSubscriptions result counts
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user