From ddf912804fc4cb26d388283eacca63a0aeddf779 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 29 Nov 2020 16:02:57 +0900 Subject: Make background operations as a operator --- src/background/operators/impls/RepeatLastOperator.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/background/operators/impls/RepeatLastOperator.ts (limited to 'src/background/operators/impls/RepeatLastOperator.ts') diff --git a/src/background/operators/impls/RepeatLastOperator.ts b/src/background/operators/impls/RepeatLastOperator.ts new file mode 100644 index 0000000..d46daab --- /dev/null +++ b/src/background/operators/impls/RepeatLastOperator.ts @@ -0,0 +1,18 @@ +import Operator from "../Operator"; +import RepeatRepository from "../../repositories/RepeatRepository"; +import OperatorFactory from "../OperatorFactory"; + +export default class RepeatLastOperator implements Operator { + constructor( + private readonly repeatRepository: RepeatRepository, + private readonly operatorFactory: OperatorFactory + ) {} + + run(): Promise { + const op = this.repeatRepository.getLastOperation(); + if (typeof op === "undefined") { + return Promise.resolve(); + } + return this.operatorFactory.create(op).run(); + } +} -- cgit v1.2.3