aboutsummaryrefslogtreecommitdiff
path: root/src/background/operators/impls/RepeatOperatorFactoryChain.ts
blob: 5038d48fa7e7742b66ee16d2857340286cfe422b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { inject, injectable } from "tsyringe";
import Operator from "../Operator";
import OperatorFactoryChain from "../OperatorFactoryChain";
import RepeatLastOperator from "./RepeatLastOperator";
import RepeatRepository from "../../repositories/RepeatRepository";
import OperatorFactory from "../OperatorFactory";
import * as operations from "../../../shared/operations";

@injectable()
export default class RepeatOperatorFactoryChain
  implements OperatorFactoryChain {
  constructor(
    @inject("RepeatRepository")
    private readonly repeatRepository: RepeatRepository,
    @inject("OperatorFactory")
    private readonly operatorFactory: OperatorFactory
  ) {}

  create(op: operations.Operation): Operator | null {
    switch (op.type) {
      case operations.REPEAT_LAST:
        return new RepeatLastOperator(
          this.repeatRepository,
          this.operatorFactory
        );
    }
    return null;
  }
}