Abstract
Abstract base class for all match operation commands. Stores the minimal diff required to undo/redo: the affected match index and the before/after states of that match.
abstract class BaseCommand implements Command { protected metadata: CommandMetadata; constructor( protected matchIndex: number, protected beforeState: MangaMatchResult, protected afterState: MangaMatchResult, protected onExecute: OnExecuteCallback, type: CommandType, description: string, ) { this.metadata = { type, timestamp: Date.now(), affectedTitles: [beforeState.kenmeiManga.title], description, }; } /** * Execute the command (apply "after" state). * @source */ execute(): void { this.onExecute(this.afterState); } /** * Undo the command (restore "before" state). * @source */ undo(): void { this.onExecute(this.beforeState); } /** * Get user-friendly description of what this command does. * @source */ getDescription(): string { return this.metadata.description; } /** * Get metadata about this command. * @source */ getMetadata(): CommandMetadata { return this.metadata; }} Copy
abstract class BaseCommand implements Command { protected metadata: CommandMetadata; constructor( protected matchIndex: number, protected beforeState: MangaMatchResult, protected afterState: MangaMatchResult, protected onExecute: OnExecuteCallback, type: CommandType, description: string, ) { this.metadata = { type, timestamp: Date.now(), affectedTitles: [beforeState.kenmeiManga.title], description, }; } /** * Execute the command (apply "after" state). * @source */ execute(): void { this.onExecute(this.afterState); } /** * Undo the command (restore "before" state). * @source */ undo(): void { this.onExecute(this.beforeState); } /** * Get user-friendly description of what this command does. * @source */ getDescription(): string { return this.metadata.description; } /** * Get metadata about this command. * @source */ getMetadata(): CommandMetadata { return this.metadata; }}
Execute the command (apply "after" state).
execute(): void { this.onExecute(this.afterState); } Copy
execute(): void { this.onExecute(this.afterState); }
Undo the command (restore "before" state).
undo(): void { this.onExecute(this.beforeState); } Copy
undo(): void { this.onExecute(this.beforeState); }
Get user-friendly description of what this command does.
getDescription(): string { return this.metadata.description; } Copy
getDescription(): string { return this.metadata.description; }
Get metadata about this command.
getMetadata(): CommandMetadata { return this.metadata; } Copy
getMetadata(): CommandMetadata { return this.metadata; }
Abstract base class for all match operation commands. Stores the minimal diff required to undo/redo: the affected match index and the before/after states of that match.
Source