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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import { inject, injectable } from "tsyringe";
import OperatorFactory from "../OperatorFactory";
import BackgroundOperationOperator from "./BackgroundOperationOperator";
import Operator from "../Operator";
import OperatorFactoryChain from "../OperatorFactoryChain";
import { Operation } from "../../../shared/operations";
import OperationClient from "../../client/OperationClient";
import AddonOperatorFactoryChain from "./AddonOperatorFactoryChain";
import ClipboardOperatorFactoryChain from "./ClipboardOperatorFactoryChain";
import FocusOperatorFactoryChain from "./FocusOperatorFactoryChain";
import FollowOperatorFactoryChain from "./FollowOperatorFactoryChain";
import MarkOperatorFactoryChain from "./MarkOperatorFactoryChain";
import ScrollOperatorFactoryChain from "./ScrollOperatorFactoryChain";
@injectable()
export default class OperatorFactoryImpl implements OperatorFactory {
private readonly factoryChains: OperatorFactoryChain[];
constructor(
addonOperatorFactoryChain: AddonOperatorFactoryChain,
clipboardOperatorFactoryChain: ClipboardOperatorFactoryChain,
focusOperatorFactoryChain: FocusOperatorFactoryChain,
followOperatorFactoryChain: FollowOperatorFactoryChain,
markOperatorFactoryChain: MarkOperatorFactoryChain,
scrollOperatorFactoryChain: ScrollOperatorFactoryChain,
@inject("OperationClient")
private readonly operationClient: OperationClient
) {
this.factoryChains = [
addonOperatorFactoryChain,
clipboardOperatorFactoryChain,
focusOperatorFactoryChain,
followOperatorFactoryChain,
markOperatorFactoryChain,
scrollOperatorFactoryChain,
];
}
create(op: Operation, repeat: number): Operator {
for (const chain of this.factoryChains) {
const operator = chain.create(op, repeat);
if (operator != null) {
return operator;
}
}
return new BackgroundOperationOperator(this.operationClient, repeat, op);
}
}
|