blob: d90aba9ae5a032ef5cc90810f698d267cb1eb465 (
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
30
31
32
33
34
35
36
37
38
39
|
import { inject, injectable } from "tsyringe";
import Operator from "../Operator";
import OperatorFactoryChain from "../OperatorFactoryChain";
import MarkKeyRepository from "../../repositories/MarkKeyRepository";
import * as operations from "../../../shared/operations";
export class EnableSetMarkOperator implements Operator {
constructor(private readonly repository: MarkKeyRepository) {}
async run(): Promise<void> {
this.repository.enableSetMode();
}
}
export class EnableJumpMarkOperator implements Operator {
constructor(private readonly repository: MarkKeyRepository) {}
async run(): Promise<void> {
this.repository.enableJumpMode();
}
}
@injectable()
export class MarkOperatorFactoryChain implements OperatorFactoryChain {
constructor(
@inject("MarkKeyRepository")
private readonly markKeyRepository: MarkKeyRepository
) {}
create(op: operations.Operation, _repeat: number): Operator | null {
switch (op.type) {
case operations.MARK_SET_PREFIX:
return new EnableSetMarkOperator(this.markKeyRepository);
case operations.MARK_JUMP_PREFIX:
return new EnableJumpMarkOperator(this.markKeyRepository);
}
return null;
}
}
|