import { EventSource } from '@/infrastructure/Events/EventSource'; import type { IEventSource } from '@/infrastructure/Events/IEventSource'; import type { FunctionKeys } from '@/TypeHelpers'; export abstract class StubWithObservableMethodCalls { public readonly callHistory = new Array>(); private readonly notifiableMethodCalls = new EventSource>(); public get methodCalls(): IEventSource> { return this.notifiableMethodCalls; } protected registerMethodCall(name: MethodCall) { this.callHistory.push(name); this.notifiableMethodCalls.notify(name); } } export type MethodCall = { [K in FunctionKeys]: { readonly methodName: K; readonly args: T[K] extends (...args: infer A) => unknown ? A : never; } }[FunctionKeys];