All files / lib/core/events eventExecutor.js

100% Statements 24/24
100% Branches 3/3
100% Functions 2/2
100% Lines 24/24

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 24 2511x 11x 11x 11x 11x 11x 11x 11x 19x 19x 19x 19x 19x 11x 11x 11x 11x 11x 11x 11x 11x 2x 2x 11x  
/**
 * Handles the execution of event handlers.
 */
export class EventExecutor {
    /**
     * @param {function(string, Event|null): any} runHandler - Function that executes the event logic.
     */
    constructor(runHandler) {
        /**
         * @type {function(string, Event|null): any}
         */
        this.runHandler = runHandler;
    }
 
    /**
     * Executes the event handler for a given source.
     * @param {string} source - The source code or identifier for the event handler.
     * @param {Event|null} [event=null] - The event object, if any.
     * @returns {any} The result of the event handler execution.
     */
    execute(source, event = null) {
        return this.runHandler(source, event);
    }
}