Source

ui/DecafEventHandler.ts

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 {
  
  /**
   * @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)}`);
  }
}