import { Model } from "@decaf-ts/decorator-validation";
import { DecafComponent } from "./DecafComponent";
/**
* @description Class representing an event handler
* @summary Defines the structure for handling events in the UI decorators system
* This class provides a foundation for managing and processing events that occur
* within the UI components generated by the decorators.
* @class EventHandler
* @memberOf module:ui-decorators/ui
*/
export class DecafEventHandler extends DecafComponent<Model> {
/**
* @description Creates an instance of DecafEventHandler
* @summary Initializes a new EventHandler object
* This constructor currently doesn't take any parameters, but it can be
* extended in the future to accept configuration options if needed.
*/
constructor() {
super();
}
/**
* Handles an event with the provided arguments.
* Logs the event handling process, including the component name and the arguments passed.
*
* @param args - The arguments for the event handler.
* @returns void
*/
handle(...args: unknown[]): void {
this.log
.for(this.handle)
.info(`component ${this.componentName} handling ${JSON.stringify(args)}`);
}
/**
* Handles an click event with the provided arguments.
* Logs the event handling process, including the component name and the arguments passed.
*
* @param args - The arguments for the event handler.
* @returns void
*/
handleClick(...args: unknown[]): void {
this.log
.for(this.handleClick)
.info(
`component ${this.componentName} handling click ${JSON.stringify(args)}`
);
}
/**
* Handles an click event with the provided arguments.
* Logs the event handling process, including the component name and the arguments passed.
*
* @param args - The arguments for the event handler.
* @returns void
*/
handleAction(...args: unknown[]): void {
this.log
.for(this.handleAction)
.info(
`component ${this.componentName} handling action ${JSON.stringify(args)}`
);
}
}
Source