(abstract) new GUICommand()
Abstract base class for all GUI-related commands in the JSCircuit Editor.
- Description:
Abstract base class for all GUI-related commands in the JSCircuit Editor.
This class implements the Command Pattern, providing a standardized interface for encapsulating user actions and enabling features like undo/redo, command queuing, and macro recording.
Command Pattern Benefits:
- Decouples GUI interactions from business logic
- Enables undo/redo functionality through command history
- Provides consistent interface for all user actions
- Supports command composition and macro operations
Usage in Architecture: All user interactions (add element, delete element, move, etc.) are implemented as concrete commands extending this base class. Commands are registered in GUICommandRegistry and executed through CommandHistory for undo support.
- Source:
Example
class CustomCommand extends GUICommand {
constructor(circuitService) {
super();
this.circuitService = circuitService;
}
execute() {
// Implement specific command logic
}
undo() {
// Implement undo logic
}
}