UNPKG

@synet/patterns

Version:

Robust, battle-tested collection of stable patterns used in Synet packages

46 lines (45 loc) 996 B
/** * Interface for all command objects */ export interface Command { /** * Executes the command */ execute(): void; } /** * Interface for commands that can be undone */ export interface UndoableCommand extends Command { /** * Undoes the command, restoring the previous state */ undo(): void; } /** * Manages the execution of commands and keeps track of command history */ export declare class CommandInvoker { private history; /** * Executes a command */ execute(command: Command): void; /** * Undoes the most recently executed command * @returns true if a command was undone, false if there was no command to undo */ undo(): boolean; /** * Clears the command history */ clearHistory(): void; /** * Returns the number of undoable commands in history */ historyLength(): number; /** * Type guard to check if a command is undoable */ private isUndoable; }