summaryrefslogtreecommitdiff
path: root/apps/web/src/lib/commands/batch-command.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/src/lib/commands/batch-command.ts')
-rw-r--r--apps/web/src/lib/commands/batch-command.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/apps/web/src/lib/commands/batch-command.ts b/apps/web/src/lib/commands/batch-command.ts
new file mode 100644
index 00000000..05b51d38
--- /dev/null
+++ b/apps/web/src/lib/commands/batch-command.ts
@@ -0,0 +1,25 @@
+import { Command } from "./base-command";
+
+export class BatchCommand extends Command {
+ constructor(private commands: Command[]) {
+ super();
+ }
+
+ execute(): void {
+ for (const command of this.commands) {
+ command.execute();
+ }
+ }
+
+ undo(): void {
+ for (const command of [...this.commands].reverse()) {
+ command.undo();
+ }
+ }
+
+ redo(): void {
+ for (const command of this.commands) {
+ command.execute();
+ }
+ }
+}