Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 7x 7x 7x 132x 132x 8x 8x 5x 3x | /* eslint-disable @typescript-eslint/no-explicit-any */
import { CallbackErrorBehavior, LoggerFunction } from '../types/CommonTypes';
import { EngineEventTrigger } from './EngineEventTrigger';
export class EngineCallbackHandler<T extends (...args: any[]) => any> extends EngineEventTrigger<T> {
constructor(private handler: () => T | undefined, logger?: LoggerFunction) {
super(logger);
}
/**
* Executes the defined handler with the provided arguments.
*
* @param args The arguments to pass to the callbacks.
* @returns The result of executing the callbacks.
*/
trigger(...args: Parameters<T>): ReturnType<T> {
const handler = this.handler();
if (handler) {
return this.createEventHandlerFn(handler, CallbackErrorBehavior.throw)(...args);
}
return undefined as ReturnType<T>;
}
}
|