From e0c4182f14f908d13c8c814c7bc2b48a1791f881 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 19 May 2019 09:26:52 +0900 Subject: Follow as a clean architecture --- src/content/controllers/FollowKeyController.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/content/controllers/FollowKeyController.ts (limited to 'src/content/controllers/FollowKeyController.ts') diff --git a/src/content/controllers/FollowKeyController.ts b/src/content/controllers/FollowKeyController.ts new file mode 100644 index 0000000..eb45e01 --- /dev/null +++ b/src/content/controllers/FollowKeyController.ts @@ -0,0 +1,21 @@ +import FollowSlaveUseCase from '../usecases/FollowSlaveUseCase'; +import Key from '../domains/Key'; + +export default class FollowKeyController { + private followSlaveUseCase: FollowSlaveUseCase; + + constructor({ + followSlaveUseCase = new FollowSlaveUseCase(), + } = {}) { + this.followSlaveUseCase = followSlaveUseCase; + } + + press(key: Key): boolean { + if (!this.followSlaveUseCase.isFollowMode()) { + return false; + } + + this.followSlaveUseCase.sendKey(key); + return true; + } +} -- cgit v1.2.3